From 57657884edaba84dba0e2af40fc99b5ed0f1e1b2 Mon Sep 17 00:00:00 2001 From: polochang-circle Date: Fri, 13 Nov 2026 09:50:56 +0800 Subject: [PATCH] fix: grant contents permission in job-level permission blocks The pr-scan and attach-release-assets jobs declare a job-level permissions block with id-token: write only. A job-level block replaces the full token permission set, so the workflow-level permissions do not apply to these jobs. As a result, the token has metadata: read only. actions/checkout cannot clone a private calling repository, and the release job cannot upload assets. Add the permissions that each job needs to its job-level block: - pr-scan: contents: read, pull-requests: write, id-token: write - attach-release-assets: contents: write, id-token: write Document in the README that a calling job must grant id-token: write. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/attach-release-assets.yaml | 3 +++ .github/workflows/pr-scan.yaml | 4 ++++ README.md | 20 ++++++++++++++++++++ 3 files changed, 27 insertions(+) diff --git a/.github/workflows/attach-release-assets.yaml b/.github/workflows/attach-release-assets.yaml index b34ac87..833414f 100644 --- a/.github/workflows/attach-release-assets.yaml +++ b/.github/workflows/attach-release-assets.yaml @@ -70,7 +70,10 @@ jobs: release_attach_assets: runs-on: ${{ inputs.runs-on }} if: github.event_name == 'push' && format('refs/heads/{0}', github.event.repository.default_branch) == github.ref + # A job-level permissions block replaces the full token permission set. + # List every permission that this job needs. permissions: + contents: write id-token: write steps: diff --git a/.github/workflows/pr-scan.yaml b/.github/workflows/pr-scan.yaml index 47cdc2c..bbabed6 100644 --- a/.github/workflows/pr-scan.yaml +++ b/.github/workflows/pr-scan.yaml @@ -43,7 +43,11 @@ on: jobs: scan: runs-on: ${{ inputs.runs-on }} + # A job-level permissions block replaces the full token permission set. + # List every permission that this job needs. permissions: + contents: read + pull-requests: write id-token: write steps: diff --git a/README.md b/README.md index 08c5244..0a5d622 100644 --- a/README.md +++ b/README.md @@ -10,3 +10,23 @@ This repository contains the following shareable workflows under `.github/workfl * attach-release-assets - Attaches SBOM and other build artifacts to releases along with a manifest file. * conventional-commit-release - Lints commit messages and PR titles to ensure compliance with [Conventional Commits](https://www.conventionalcommits.org); on default branch builds it will execute the [release-please action](https://github.com/google-github-actions/release-please-action) to generate Github releases & changelogs. * pr-scan - Executes the [dependency-review-action](https://github.com/actions/dependency-review-action) to check for vulnerabilities and license compliance in pull request dependencies. + +## Permissions + +The `pr-scan` and `attach-release-assets` jobs request `id-token: write`. The calling job must grant it, or the run fails before it starts. + +```yaml +jobs: + scan: + uses: circlefin/circle-public-github-workflows/.github/workflows/pr-scan.yaml@v1 + permissions: + contents: read + pull-requests: write + id-token: write + + release-sbom: + uses: circlefin/circle-public-github-workflows/.github/workflows/attach-release-assets.yaml@v1 + permissions: + contents: write + id-token: write +```