Skip to content

Commit ca35c49

Browse files
0x46616c6bOpenCode
andcommitted
docs: add required permissions to all caller examples in README
Add explicit permissions blocks to all 17 usage examples and the generic template in the README. Also add a note in the Limitations section explaining that reusable workflows can only restrict GITHUB_TOKEN permissions, not escalate them. Co-Authored-By: OpenCode <noreply@opencode.ai>
1 parent 4c75e64 commit ca35c49

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ on: ...
1414
jobs:
1515
<action name>:
1616
uses: Staffbase/gha-workflows/.github/workflows/template_*.yml@v11.0.1
17+
permissions: ... # see individual examples below
1718
with: ...
1819
```
1920
@@ -42,6 +43,7 @@ on:
4243
jobs:
4344
dependabot:
4445
uses: Staffbase/gha-workflows/.github/workflows/template_automerge_dependabot.yml@v11.0.1
46+
permissions: {}
4547
with:
4648
# optional: ⚠️ only enable the force merge if you want to do the merge just now
4749
force: true
@@ -77,6 +79,8 @@ on:
7779
jobs:
7880
autodev:
7981
uses: Staffbase/gha-workflows/.github/workflows/template_autodev.yml@v11.0.1
82+
permissions:
83+
contents: read
8084
with:
8185
# optional: base branch from which the history originates, default: main
8286
base: master
@@ -121,6 +125,9 @@ on:
121125
jobs:
122126
changeset-check:
123127
uses: Staffbase/gha-workflows/.github/workflows/template_changeset_check.yml@v11.0.1
128+
permissions:
129+
contents: read
130+
pull-requests: write
124131
```
125132
126133
</details>
@@ -143,6 +150,8 @@ on:
143150
jobs:
144151
changeset-release:
145152
uses: Staffbase/gha-workflows/.github/workflows/template_changeset_release.yml@v11.0.1
153+
permissions:
154+
contents: read
146155
with:
147156
# optional: The file containing the Node.js version to use, defaults to .nvmrc
148157
node-version-file: '.node-version'
@@ -181,6 +190,7 @@ on:
181190
jobs:
182191
flaky-tests:
183192
uses: Staffbase/gha-workflows/.github/workflows/template_flaky_tests.yml@v11.0.1
193+
permissions: {}
184194
with:
185195
# identifier for the slack channel
186196
slack-channel-id: 45678787976
@@ -215,6 +225,8 @@ on: [push]
215225
jobs:
216226
gitops:
217227
uses: Staffbase/gha-workflows/.github/workflows/template_gitops.yml@v11.0.1
228+
permissions:
229+
contents: read
218230
with:
219231
# optional: host of the docker registry, default: "registry.staffbase.com"
220232
docker-registry: '<your-registry>'
@@ -302,6 +314,8 @@ on:
302314
jobs:
303315
jira_annotate:
304316
uses: Staffbase/gha-workflows/.github/workflows/template_jira_tagging.yml@v11.0.1
317+
permissions:
318+
contents: read
305319
with:
306320
# optional: name of the service to add as label, default: name of the repository
307321
name: 'component name'
@@ -335,6 +349,8 @@ on:
335349
jobs:
336350
ld_code_references:
337351
uses: Staffbase/gha-workflows/.github/workflows/template_launchdarkly_code_references.yml@v11.0.1
352+
permissions:
353+
contents: read
338354
with:
339355
# optional: key of the LD project, default: default
340356
project-key: 'my-project'
@@ -360,6 +376,8 @@ on:
360376
jobs:
361377
block:
362378
uses: Staffbase/gha-workflows/.github/workflows/template_merge_block.yml@v11.0.1
379+
permissions:
380+
pull-requests: write
363381
with:
364382
# optional: name of the label if the PR should not be merged, default: do not merge
365383
label: merge block
@@ -388,6 +406,9 @@ on:
388406
jobs:
389407
update_release_draft:
390408
uses: Staffbase/gha-workflows/.github/workflows/template_release_drafter.yml@v11.0.1
409+
permissions:
410+
contents: write
411+
pull-requests: read
391412
with:
392413
# optional: name of the release drafter configuration file, default: release-drafter.yml
393414
config-name: release-drafter-test.yml
@@ -433,6 +454,8 @@ on:
433454
jobs:
434455
new_version:
435456
uses: Staffbase/gha-workflows/.github/workflows/template_release_version.yml@v11.0.1
457+
permissions:
458+
contents: read
436459
with:
437460
# optional: prefix of the tag in order to find the last release; this is useful for multi artifact/service repositories, default: 'v'
438461
tag-prefix: 'app-v'
@@ -468,6 +491,8 @@ on: [pull_request]
468491
jobs:
469492
trufflehog:
470493
uses: Staffbase/gha-workflows/.github/workflows/template_secret_scan.yml@v11.0.1
494+
permissions:
495+
contents: read
471496
```
472497

473498
</details>
@@ -487,6 +512,10 @@ on:
487512
jobs:
488513
stale:
489514
uses: Staffbase/gha-workflows/.github/workflows/template_stale.yml@v11.0.1
515+
permissions:
516+
contents: write
517+
pull-requests: write
518+
issues: write
490519
with:
491520
# optional: comment on the stale pull request while closed, default: This stale PR was closed because there was no activity.
492521
close-pr-message: your message
@@ -524,6 +553,8 @@ on:
524553
jobs:
525554
techdocs:
526555
uses: Staffbase/gha-workflows/.github/workflows/template_techdocs_monorepo.yml@v11.0.1
556+
permissions:
557+
contents: read
527558
secrets:
528559
# required: specifies an Azure Storage account name
529560
azure-account-name: ${{ vars.TECHDOCS_AZURE_ACCOUNT_NAME }}
@@ -553,6 +584,8 @@ on:
553584
jobs:
554585
techdocs:
555586
uses: Staffbase/gha-workflows/.github/workflows/template_techdocs.yml@v11.0.1
587+
permissions:
588+
contents: read
556589
with:
557590
# optional: kind of the Backstage entity, default: Component
558591
# ref: https://backstage.io/docs/features/software-catalog/descriptor-format#contents
@@ -583,6 +616,9 @@ on: [pull_request]
583616
jobs:
584617
terraform:
585618
uses: Staffbase/gha-workflows/.github/workflows/template_terraform_format.yml@v11.0.1
619+
permissions:
620+
contents: read
621+
pull-requests: write
586622
with:
587623
# optional: Terraform version, default: latest
588624
terraform-version: latest
@@ -616,6 +652,9 @@ on:
616652
jobs:
617653
yamllint:
618654
uses: Staffbase/gha-workflows/.github/workflows/template_yaml.yml@v11.0.1
655+
permissions:
656+
contents: read
657+
checks: write
619658
with:
620659
# optional: name of the running action, default: yamllint / yamllint
621660
action-name: your name
@@ -631,6 +670,8 @@ With the current implementation of the reusable workflows from GitHub, we have s
631670

632671
- It isn't possible to [access environment variables][reusable-workflow-env] and [secrets][reusable-workflow-secrets], so it's necessary to pass them to the workflow. But we don't want to do it for all secrets.
633672

673+
- Reusable workflows can only restrict `GITHUB_TOKEN` permissions, not escalate them. The calling workflow must grant at least the permissions required by the reusable workflow. All examples above include the minimum required `permissions` for each workflow. For more details, see the [GitHub documentation][reusable-workflow-permissions].
674+
634675
There are also some [further limitations][further-limitations] if you want to use the `GITHUB_TOKEN`.
635676

636677
## Release 🔖
@@ -662,4 +703,5 @@ This project is licensed under the Apache-2.0 License - see the [LICENSE.md](LIC
662703
[release-new]: https://github.com/Staffbase/gha-workflows/releases
663704
[reusable-workflow-secrets]: https://github.com/orgs/community/discussions/17554
664705
[reusable-workflow-env]: https://github.com/orgs/community/discussions/26671
706+
[reusable-workflow-permissions]: https://docs.github.com/en/actions/sharing-automations/reusing-workflows#supported-keywords-for-jobs-that-call-a-reusable-workflow
665707
[further-limitations]: https://docs.github.com/en/actions/security-guides/automatic-token-authentication#using-the-github_token-in-a-workflow

0 commit comments

Comments
 (0)