@@ -14,6 +14,7 @@ on: ...
1414jobs :
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
4243jobs :
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
7779jobs :
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
121125jobs :
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>
143150jobs:
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'
181190jobs :
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]
215225jobs :
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>'
302314jobs :
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'
335349jobs :
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'
360376jobs :
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
388406jobs:
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
433454jobs:
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]
468491jobs:
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>
487512jobs:
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
524553jobs:
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 }}
553584jobs:
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]
583616jobs:
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
616652jobs:
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+
634675There 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