Skip to content

Commit

Permalink
CI: consistency with job permissions (#1212)
Browse files Browse the repository at this point in the history
  • Loading branch information
emmercm committed Jul 12, 2024
1 parent 865955a commit 0f0c9aa
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 30 deletions.
15 changes: 8 additions & 7 deletions .github/workflows/gh-automerge-disabler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,15 @@ on:
types:
- edited

permissions:
# actions/checkout@v4, `gh` CLI
contents: write
# `gh` CLI
repository-projects: read
pull-requests: write

jobs:
disable-auto-merge:
if: ${{ github.event.pull_request.auto_merge && github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name }}
permissions:
# actions/checkout@v4, `gh` CLI
contents: write
# `gh` CLI
repository-projects: read
pull-requests: write
runs-on: ubuntu-latest
steps:
# Required for `gh` CLI
Expand All @@ -39,6 +38,8 @@ jobs:

remove-comment:
if: ${{ !github.event.pull_request.auto_merge || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name }}
permissions:
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: thollander/actions-comment-pull-request@v2
Expand Down
13 changes: 6 additions & 7 deletions .github/workflows/gh-dependabot-automerge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,15 @@ on:
- reopened
- synchronize # PR's branch was edited (i.e. new commits)

permissions:
# actions/checkout@v4, `gh` CLI
contents: write
# `gh` CLI
repository-projects: read
pull-requests: write

jobs:
dependabot-automerge:
if: ${{ github.event.pull_request.user.login == 'dependabot[bot]' }}
permissions:
# actions/checkout@v4, `gh` CLI
contents: write
# `gh` CLI
repository-projects: read
pull-requests: write
runs-on: ubuntu-latest
steps:
# Required for `gh` CLI
Expand Down
9 changes: 4 additions & 5 deletions .github/workflows/gh-lock-issues.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@ on:
- cron: '30 1 * * *'
workflow_dispatch:

permissions:
issues: write
pull-requests: write
discussions: write

jobs:
action:
permissions:
issues: write
pull-requests: write
discussions: write
runs-on: ubuntu-latest
steps:
- uses: dessant/lock-threads@v5
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ concurrency:

jobs:
path-filter:
runs-on: ubuntu-latest
permissions:
pull-requests: read
runs-on: ubuntu-latest
outputs:
changes: ${{ steps.filter.outputs.changes }}
steps:
Expand Down Expand Up @@ -82,9 +82,9 @@ jobs:

deploy:
if: github.event_name == 'release'
runs-on: ubuntu-latest
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/gh-release-drafter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ env:

jobs:
release:
permissions:
# actions/checkout@v4
contents: read
# thollander/actions-comment-pull-request@v2
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -36,7 +41,6 @@ jobs:
- id: check
uses: EndBug/version-check@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
# NOTE: `diff-search:true` is preferred so that only the exact commit that bumps the
# version triggers this workflow, but `workflow_dispatch` doesn't carry commit or
# commit ref info that's needed for it.
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/gh-repo-update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ concurrency:

jobs:
repo-update:
runs-on: ubuntu-latest
permissions:
repository-projects: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: |
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/gh-stale-issues.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ on:
- cron: '30 1 * * *'
workflow_dispatch:

permissions:
issues: write
pull-requests: write

jobs:
stale:
permissions:
issues: write
pull-requests: write
discussions: write
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v9
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/node-compile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ env:

jobs:
path-filter:
runs-on: ubuntu-latest
permissions:
pull-requests: read
runs-on: ubuntu-latest
outputs:
changes: ${{ steps.filter.outputs.changes }}
steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/node-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ on:

jobs:
node-publish:
runs-on: ubuntu-latest
permissions:
# actions/checkout@v4
contents: read
# `npm publish --provenance`
id-token: write
# thollander/actions-comment-pull-request@v2
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: volta-cli/action@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/node-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ env:

jobs:
path-filter:
runs-on: ubuntu-latest
permissions:
pull-requests: read
runs-on: ubuntu-latest
outputs:
changes: ${{ steps.filter.outputs.changes }}
steps:
Expand Down

0 comments on commit 0f0c9aa

Please sign in to comment.