Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GHA security cleanup #3710

Merged
merged 3 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/assign-milestone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ on:
types: [closed]
branches: [main]

permissions:
pull-requests: write
issues: write

jobs:
sync:
permissions:
pull-requests: write
issues: write

name: Assign Latest Milestone
runs-on: ubuntu-latest
steps:
Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/automerge-dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: Auto-merge Dependabot PRs

on:
pull_request_target:
branches: [main]

jobs:
#
Expand All @@ -12,13 +13,15 @@ jobs:
if: github.actor == 'dependabot[bot]'
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
GH_PR: ${{ github.event.pull_request.number }}

permissions:
contents: write
pull-requests: write

steps:
- name: Set auto-merge
run: gh pr merge -R ${{ github.repository }} --merge --auto ${{ github.event.pull_request.number }}
run: gh pr merge -R "$GH_REPO" --merge --auto "$GH_PR"
- name: Review PR
run: gh pr review -R ${{ github.repository }} --approve ${{ github.event.pull_request.number }}
run: gh pr review -R "$GH_REPO" --approve "$GH_PR"
15 changes: 9 additions & 6 deletions .github/workflows/backport-prs.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
name: Backport PRs

permissions:
pull-requests: write
contents: write

on:
pull_request_target:
types:
Expand All @@ -14,6 +10,13 @@ jobs:
Backport:
runs-on: ubuntu-latest
if: github.event.pull_request.merged && contains( github.event.pull_request.labels.*.name, 'backport' )
permissions:
pull-requests: write
contents: write
env:
GH_BASE_SHA: ${{ github.event.pull_request.base.sha }}
GH_HEAD_SHA: ${{ github.event.pull_request.head.sha }}

steps:
- name: Checkout PR HEAD
uses: actions/checkout@v4
Expand All @@ -22,7 +25,7 @@ jobs:
fetch-depth: 100

- name: Fetch PR merge base
run: git fetch --no-tags --depth=100 origin ${{ github.event.pull_request.base.sha }}
run: git fetch --no-tags --depth=100 origin "$GH_BASE_SHA"

- name: Set up git
run: |
Expand All @@ -38,7 +41,7 @@ jobs:
- name: Apply PR commits to ${{ steps.get-branch.outputs.backport-branch}} branch
run: |
git checkout -b ${{ steps.get-branch.outputs.backport-branch}} origin/${{ steps.get-branch.outputs.backport-branch}}
git cherry-pick -x ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}
git cherry-pick -x "$GH_BASE_SHA".."$GH_HEAD_SHA"

- name: Create backport PR
id: create-pr
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/cffcheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ jobs:
steps:
- name: Check out a copy of the repository
uses: actions/checkout@v4
with:
persist-credentials: false

- name: Check validity of CITATION.cff
uses: citation-file-format/[email protected]
Expand Down
8 changes: 5 additions & 3 deletions .github/workflows/code-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,19 @@ on:
schedule:
- cron: '0 8 * * 6'

permissions:
contents: read
security-events: write

jobs:
CodeQL:
runs-on: ubuntu-latest
permissions:
contents: read
security-events: write

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
persist-credentials: false

- name: Initialize CodeQL
uses: github/codeql-action/init@v3
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/docs-conda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ jobs:
with:
fetch-depth: 150
fetch-tags: true
persist-credentials: false

- name: Install from Conda
uses: ./.github/actions/install-conda
Expand Down
10 changes: 4 additions & 6 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ on:
- v[0-9]+.[0-9]+.[0-9]+
pull_request:

permissions:
contents: write

concurrency:
group: ${{ github.workflow}}-${{ github.head_ref }}
cancel-in-progress: true
Expand Down Expand Up @@ -40,9 +37,8 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 150

- name: Get tags
run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
fetch-tags: true
persist-credentials: false

- name: Install using PyPI
uses: ./.github/actions/install-pypi
Expand All @@ -67,6 +63,8 @@ jobs:
runs-on: ubuntu-latest
env:
DOC_VERSION: dev
permissions:
contents: write

steps:
- name: Download doc build
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false

- name: Set up Python 3
uses: actions/setup-python@v5
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false

- name: Set up Python
id: setup
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/tests-conda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ jobs:
with:
fetch-depth: 150
fetch-tags: true
persist-credentials: false

- name: Install from Conda
uses: ./.github/actions/install-conda
Expand All @@ -66,6 +67,8 @@ jobs:
steps:
- name: Checkout source
uses: actions/checkout@v4
with:
persist-credentials: false

- name: Download coverage artifacts
uses: actions/download-artifact@v4
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/tests-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ jobs:
with:
fetch-depth: 150
fetch-tags: true
persist-credentials: false

- name: Generate minimum dependencies
if: ${{ matrix.dep-versions == 'Minimum' }}
Expand Down Expand Up @@ -94,6 +95,8 @@ jobs:
steps:
- name: Checkout source
uses: actions/checkout@v4
with:
persist-credentials: false

- name: Download coverage artifacts
uses: actions/download-artifact@v4
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/unstable-builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
with:
fetch-depth: 150
fetch-tags: true
persist-credentials: false

- name: Assemble test requirements
run: |
Expand Down Expand Up @@ -61,6 +62,7 @@ jobs:
with:
fetch-depth: 150
fetch-tags: true
persist-credentials: false

- name: Assemble doc requirements
run: |
Expand Down
Loading