[CI] Restrict workflow token permissions to read-only (#25207) Workflows declare no `permissions:` block and `clang_tidy.yml` grants `contents: write` at the top level. Explicitly set permissions, restrict/default to read-only. ### Changes - Add a top-level `permissions: contents: read` to every workflow - `clang_tidy.yml`: reduce the top-level block to `contents: read`. cpp-linter runs with `thread-comments: false` and only reads the PR diff, so it never writes. - Checkouts that use `WRITE_ACCESS_TOKEN` now set `persist-credentials: false`, so the PAT is no longer written to `.git/config` while `pip install` and `curl | sh` run in the same job. The two steps that relied on the persisted credential, the candidate tag push in `schedule_candidate_release.yml` and `mkdocs gh-deploy` in `publish_website.yml`, pass the token explicitly instead. The other pushes already went through `ad-m/github-push-action` with an explicit token. ### Verification - `zizmor`: `excessive-permissions` findings 65 → 0 🤖 Generated with [Claude Code](https://claude.com/claude-code) Signed-off-by: Tobias Fuchs <fuchs@roofline.ai> Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
diff --git a/.github/workflows/build_package.yml b/.github/workflows/build_package.yml index c4138e5..2f753e1 100644 --- a/.github/workflows/build_package.yml +++ b/.github/workflows/build_package.yml
@@ -38,6 +38,9 @@ description: "Commit to check out" default: "" +permissions: + contents: read + jobs: # Note: For cross platform builds, it's useful to just generate the # metadata on Linux and pass that to later jobs using artifacts. The
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1dc5c19..12828da 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml
@@ -33,6 +33,9 @@ branches: - main +permissions: + contents: read + concurrency: # A PR number if a pull request and otherwise the commit hash. This cancels # queued and in-progress runs for the same PR (presubmit) or commit @@ -45,6 +48,10 @@ jobs: setup: uses: ./.github/workflows/setup.yml + # A called workflow can't exceed the permissions granted here. + permissions: + contents: read + pull-requests: read ############################################################################## # Runtime builds
diff --git a/.github/workflows/ci_linux_arm64_clang.yml b/.github/workflows/ci_linux_arm64_clang.yml index f36210e..f33dbf6 100644 --- a/.github/workflows/ci_linux_arm64_clang.yml +++ b/.github/workflows/ci_linux_arm64_clang.yml
@@ -13,6 +13,8 @@ workflow_dispatch: workflow_call: +permissions: + contents: read jobs: linux_arm64_clang:
diff --git a/.github/workflows/ci_linux_x64_bazel.yml b/.github/workflows/ci_linux_x64_bazel.yml index 4b3af82..8a4a151 100644 --- a/.github/workflows/ci_linux_x64_bazel.yml +++ b/.github/workflows/ci_linux_x64_bazel.yml
@@ -10,6 +10,9 @@ workflow_call: workflow_dispatch: +permissions: + contents: read + jobs: linux_x64_bazel: runs-on: azure-linux-scale
diff --git a/.github/workflows/ci_linux_x64_clang.yml b/.github/workflows/ci_linux_x64_clang.yml index 4d45936..0e95248 100644 --- a/.github/workflows/ci_linux_x64_clang.yml +++ b/.github/workflows/ci_linux_x64_clang.yml
@@ -10,6 +10,9 @@ workflow_call: workflow_dispatch: +permissions: + contents: read + jobs: linux_x64_clang: runs-on: azure-linux-scale
diff --git a/.github/workflows/ci_linux_x64_clang_asan.yml b/.github/workflows/ci_linux_x64_clang_asan.yml index 079b3a3..3b8024f 100644 --- a/.github/workflows/ci_linux_x64_clang_asan.yml +++ b/.github/workflows/ci_linux_x64_clang_asan.yml
@@ -10,6 +10,9 @@ workflow_call: workflow_dispatch: +permissions: + contents: read + jobs: linux_x64_clang_asan: runs-on: azure-linux-scale
diff --git a/.github/workflows/ci_linux_x64_clang_byollvm.yml b/.github/workflows/ci_linux_x64_clang_byollvm.yml index 4a1c74c..4e6d3d9 100644 --- a/.github/workflows/ci_linux_x64_clang_byollvm.yml +++ b/.github/workflows/ci_linux_x64_clang_byollvm.yml
@@ -13,6 +13,9 @@ workflow_dispatch: workflow_call: +permissions: + contents: read + jobs: linux_x64_clang_byollvm: if: ${{ github.repository_owner == 'iree-org' || github.event_name != 'schedule' }}
diff --git a/.github/workflows/ci_linux_x64_clang_debug.yml b/.github/workflows/ci_linux_x64_clang_debug.yml index 845d94d..f9b27ee 100644 --- a/.github/workflows/ci_linux_x64_clang_debug.yml +++ b/.github/workflows/ci_linux_x64_clang_debug.yml
@@ -13,6 +13,9 @@ workflow_dispatch: workflow_call: +permissions: + contents: read + jobs: # This may run out of memory / disk space on standard GitHub-hosted runners, # so run on self-hosted CPU build runners instead.
diff --git a/.github/workflows/ci_linux_x64_clang_dynamic_plugins.yml b/.github/workflows/ci_linux_x64_clang_dynamic_plugins.yml index a97b3e1..265759c 100644 --- a/.github/workflows/ci_linux_x64_clang_dynamic_plugins.yml +++ b/.github/workflows/ci_linux_x64_clang_dynamic_plugins.yml
@@ -10,6 +10,9 @@ workflow_call: workflow_dispatch: +permissions: + contents: read + jobs: linux_x64_clang_dynamic_plugins: runs-on: azure-linux-scale
diff --git a/.github/workflows/ci_linux_x64_clang_tsan.yml b/.github/workflows/ci_linux_x64_clang_tsan.yml index fdd9ef8..79c4a89 100644 --- a/.github/workflows/ci_linux_x64_clang_tsan.yml +++ b/.github/workflows/ci_linux_x64_clang_tsan.yml
@@ -13,6 +13,9 @@ workflow_dispatch: workflow_call: +permissions: + contents: read + jobs: linux_x64_clang_tsan: if: ${{ github.repository_owner == 'iree-org' || github.event_name != 'schedule' }}
diff --git a/.github/workflows/ci_linux_x64_clang_ubsan.yml b/.github/workflows/ci_linux_x64_clang_ubsan.yml index 618231a..99b4d8e 100644 --- a/.github/workflows/ci_linux_x64_clang_ubsan.yml +++ b/.github/workflows/ci_linux_x64_clang_ubsan.yml
@@ -10,6 +10,9 @@ workflow_call: workflow_dispatch: +permissions: + contents: read + jobs: linux_x64_clang_ubsan: runs-on: azure-linux-scale
diff --git a/.github/workflows/ci_linux_x64_gcc.yml b/.github/workflows/ci_linux_x64_gcc.yml index 8c38db5..69bb530 100644 --- a/.github/workflows/ci_linux_x64_gcc.yml +++ b/.github/workflows/ci_linux_x64_gcc.yml
@@ -13,6 +13,9 @@ workflow_dispatch: workflow_call: +permissions: + contents: read + jobs: linux_x64_gcc: if: ${{ github.repository_owner == 'iree-org' || github.event_name != 'schedule' }}
diff --git a/.github/workflows/ci_macos_arm64_clang.yml b/.github/workflows/ci_macos_arm64_clang.yml index 5ac4e0c..116d35c 100644 --- a/.github/workflows/ci_macos_arm64_clang.yml +++ b/.github/workflows/ci_macos_arm64_clang.yml
@@ -13,6 +13,9 @@ workflow_call: workflow_dispatch: +permissions: + contents: read + jobs: macos_arm64_clang: # Prevent scheduled runs in forks (only allow for iree-org or non-schedule triggers).
diff --git a/.github/workflows/ci_windows_x64_msvc.yml b/.github/workflows/ci_windows_x64_msvc.yml index e564fca..a9acb7b 100644 --- a/.github/workflows/ci_windows_x64_msvc.yml +++ b/.github/workflows/ci_windows_x64_msvc.yml
@@ -10,6 +10,9 @@ workflow_call: workflow_dispatch: +permissions: + contents: read + jobs: windows_x64_msvc: runs-on: azure-windows-scale
diff --git a/.github/workflows/clang_tidy.yml b/.github/workflows/clang_tidy.yml index e3007b6..1dda3b8 100644 --- a/.github/workflows/clang_tidy.yml +++ b/.github/workflows/clang_tidy.yml
@@ -20,8 +20,7 @@ - '.github/workflows/clang_tidy.yml' permissions: - contents: write - pull-requests: write + contents: read concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number }} @@ -33,6 +32,10 @@ if: >- github.event.pull_request.stack == null || github.event.pull_request.stack.base.ref == github.event.pull_request.base.ref + permissions: + contents: read + actions: read # Download iree-clang-tidy from a build_clang_tidy.yml run. + pull-requests: read # Fetch the PR diff (here and in cpp-linter). runs-on: ubuntu-24.04 container: image: ghcr.io/iree-org/cpubuilder_ubuntu_jammy@sha256:78a558b999b230f7e1da376639e14b44f095f30f1777d6a272ba48c0bbdd4ccb @@ -98,9 +101,13 @@ "${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/pulls/${PR_NUMBER}") if [[ "${status_code}" == "200" ]]; then echo "use_cpp_linter=true" >> "${GITHUB_OUTPUT}" - else - echo "GitHub PR diff request returned ${status_code}; running clang-tidy locally on changed files." + elif [[ "${status_code}" == "406" ]] && grep -qE '"code": ?"too_large"' /tmp/pr.diff; then + echo "GitHub refused the PR diff as too large; skipping clang-tidy." echo "use_cpp_linter=false" >> "${GITHUB_OUTPUT}" + else + echo "::error title=PR diff request failed::GitHub returned HTTP ${status_code} for the PR diff." + cat /tmp/pr.diff + exit 1 fi - name: Run clang-tidy @@ -138,4 +145,4 @@ exit 0 fi - echo "::warning title=clang-tidy skipped::GitHub refused the PR diff because it exceeds the 20,000-line API limit, so cpp-linter cannot compute changed-line diagnostics for $(wc -l < "${changed_files}") changed C/C++ files." + echo "::warning title=clang-tidy skipped::GitHub refused the PR diff as too large (the API caps diffs at 300 files and 20,000 lines), so cpp-linter cannot compute changed-line diagnostics for $(wc -l < "${changed_files}") changed C/C++ files."
diff --git a/.github/workflows/oneshot_candidate_release.yml b/.github/workflows/oneshot_candidate_release.yml index 3829624..175ec5a 100644 --- a/.github/workflows/oneshot_candidate_release.yml +++ b/.github/workflows/oneshot_candidate_release.yml
@@ -8,6 +8,9 @@ type: string default: "rc" +permissions: + contents: read + jobs: tag_release: name: "Tag candidate release" @@ -17,6 +20,7 @@ uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: token: ${{ secrets.WRITE_ACCESS_TOKEN }} + persist-credentials: false # Compute version suffix based on inputs (default to 'rc') - name: Compute stable version suffix
diff --git a/.github/workflows/pkgci.yml b/.github/workflows/pkgci.yml index b1533b4..84b94e0 100644 --- a/.github/workflows/pkgci.yml +++ b/.github/workflows/pkgci.yml
@@ -17,6 +17,9 @@ # Short term feature branches: - sdxl +permissions: + contents: read + concurrency: # A PR number if a pull request and otherwise the commit hash. This cancels # queued and in-progress runs for the same PR (presubmit) or commit @@ -28,6 +31,10 @@ jobs: setup: uses: ./.github/workflows/setup.yml + # A called workflow can't exceed the permissions granted here. + permissions: + contents: read + pull-requests: read build_packages: name: Build Packages @@ -41,6 +48,12 @@ needs: [setup, build_packages] if: contains(fromJson(needs.setup.outputs.enabled-jobs), 'unit_test') uses: ./.github/workflows/pkgci_unit_test.yml + # The pkgci test workflows need actions: read when dispatched with + # artifact_run_id, and a called workflow can't exceed its caller's + # permissions. + permissions: + contents: read + actions: read ########################### Hardware/accelerators ########################### # Jobs that run unit tests on special hardware platforms or accelerators @@ -51,12 +64,18 @@ needs: [setup, build_packages] if: contains(fromJson(needs.setup.outputs.enabled-jobs), 'test_amd_w7900') uses: ./.github/workflows/pkgci_test_amd_w7900.yml + permissions: + contents: read + actions: read test_amd_r9700: name: Test AMD R9700 needs: [setup, build_packages] if: contains(fromJson(needs.setup.outputs.enabled-jobs), 'test_amd_r9700') uses: ./.github/workflows/pkgci_test_amd_r9700.yml + permissions: + contents: read + actions: read # TODO(#18238): migrate to new runner cluster # test_nvidia_t4: @@ -64,12 +83,18 @@ # needs: [setup, build_packages] # if: contains(fromJson(needs.setup.outputs.enabled-jobs), 'test_nvidia_t4') # uses: ./.github/workflows/pkgci_test_nvidia_t4.yml + # permissions: + # contents: read + # actions: read test_android: name: Test Android needs: [setup, build_packages] if: contains(fromJson(needs.setup.outputs.enabled-jobs), 'test_android') uses: ./.github/workflows/pkgci_test_android.yml + permissions: + contents: read + actions: read with: write-caches: ${{ needs.setup.outputs.write-caches }} @@ -78,6 +103,9 @@ needs: [setup, build_packages] if: contains(fromJson(needs.setup.outputs.enabled-jobs), 'test_riscv64') uses: ./.github/workflows/pkgci_test_riscv64.yml + permissions: + contents: read + actions: read with: write-caches: ${{ needs.setup.outputs.write-caches }} @@ -90,30 +118,45 @@ needs: [setup, build_packages] if: contains(fromJson(needs.setup.outputs.enabled-jobs), 'test_onnx') uses: ./.github/workflows/pkgci_test_onnx.yml + permissions: + contents: read + actions: read test_sharktank: name: Test Sharktank needs: [setup, build_packages] if: contains(fromJson(needs.setup.outputs.enabled-jobs), 'test_sharktank') uses: ./.github/workflows/pkgci_test_sharktank.yml + permissions: + contents: read + actions: read test_torch: name: Test Torch needs: [setup, build_packages] if: contains(fromJson(needs.setup.outputs.enabled-jobs), 'test_torch') uses: ./.github/workflows/pkgci_test_torch.yml + permissions: + contents: read + actions: read test_tensorflow: name: Test TensorFlow needs: [setup, build_packages] if: contains(fromJson(needs.setup.outputs.enabled-jobs), 'test_tensorflow') uses: ./.github/workflows/pkgci_test_tensorflow.yml + permissions: + contents: read + actions: read test_pjrt: name: Test PJRT plugin needs: [setup, build_packages] if: contains(fromJson(needs.setup.outputs.enabled-jobs), 'test_pjrt') uses: ./.github/workflows/pkgci_test_pjrt.yml + permissions: + contents: read + actions: read with: write-caches: ${{ needs.setup.outputs.write-caches }}
diff --git a/.github/workflows/pkgci_build_packages.yml b/.github/workflows/pkgci_build_packages.yml index 0602ce0..bb6552b 100644 --- a/.github/workflows/pkgci_build_packages.yml +++ b/.github/workflows/pkgci_build_packages.yml
@@ -8,6 +8,9 @@ on: workflow_call: +permissions: + contents: read + jobs: linux_x86_64_release_packages: name: Linux Release (x86_64)
diff --git a/.github/workflows/pkgci_test_amd_r9700.yml b/.github/workflows/pkgci_test_amd_r9700.yml index 1b2ec8f..1892427 100644 --- a/.github/workflows/pkgci_test_amd_r9700.yml +++ b/.github/workflows/pkgci_test_amd_r9700.yml
@@ -17,8 +17,14 @@ type: string default: "" +permissions: + contents: read + jobs: test_r9700: + permissions: + contents: read + actions: read # setup_venv.py --fetch-gh-workflow (dispatch with artifact_run_id). runs-on: [Linux, X64, iree-r9700] env: PACKAGE_DOWNLOAD_DIR: ${{ github.workspace }}/.packages
diff --git a/.github/workflows/pkgci_test_amd_w7900.yml b/.github/workflows/pkgci_test_amd_w7900.yml index 9de71d8..2cd5f86 100644 --- a/.github/workflows/pkgci_test_amd_w7900.yml +++ b/.github/workflows/pkgci_test_amd_w7900.yml
@@ -17,10 +17,16 @@ type: string default: "" +permissions: + contents: read + jobs: test_w7900: # Disabled until an iree-w7900 runner is available. if: false + permissions: + contents: read + actions: read # setup_venv.py --fetch-gh-workflow (dispatch with artifact_run_id). runs-on: [Linux, X64, iree-w7900] env: PACKAGE_DOWNLOAD_DIR: ${{ github.workspace }}/.packages
diff --git a/.github/workflows/pkgci_test_android.yml b/.github/workflows/pkgci_test_android.yml index cb58ffb..9639a3c 100644 --- a/.github/workflows/pkgci_test_android.yml +++ b/.github/workflows/pkgci_test_android.yml
@@ -32,6 +32,9 @@ jobs: android_arm64: + permissions: + contents: read + actions: read # setup_venv.py --fetch-gh-workflow (dispatch with artifact_run_id). runs-on: ubuntu-24.04 env: PACKAGE_DOWNLOAD_DIR: ${{ github.workspace }}/.packages
diff --git a/.github/workflows/pkgci_test_nvidia_t4.yml b/.github/workflows/pkgci_test_nvidia_t4.yml index 08e8d5f..e99b31a 100644 --- a/.github/workflows/pkgci_test_nvidia_t4.yml +++ b/.github/workflows/pkgci_test_nvidia_t4.yml
@@ -17,8 +17,14 @@ type: string default: "" +permissions: + contents: read + jobs: test_t4: + permissions: + contents: read + actions: read # setup_venv.py --fetch-gh-workflow (dispatch with artifact_run_id). # TODO(#18238): migrate to new runner cluster runs-on: - self-hosted # must come first
diff --git a/.github/workflows/pkgci_test_onnx.yml b/.github/workflows/pkgci_test_onnx.yml index 9b01ad8..756ac49 100644 --- a/.github/workflows/pkgci_test_onnx.yml +++ b/.github/workflows/pkgci_test_onnx.yml
@@ -17,9 +17,15 @@ type: string default: "" +permissions: + contents: read + jobs: test_onnx_ops: name: "test_onnx_ops :: ${{ matrix.name }}" + permissions: + contents: read + actions: read # setup_venv.py --fetch-gh-workflow (dispatch with artifact_run_id). runs-on: ${{ matrix.runs-on }} strategy: fail-fast: false @@ -136,6 +142,9 @@ test_onnx_models: name: "test_onnx_models :: ${{ matrix.name }}" + permissions: + contents: read + actions: read # setup_venv.py --fetch-gh-workflow (dispatch with artifact_run_id). runs-on: ${{ matrix.runs-on }} strategy: fail-fast: false
diff --git a/.github/workflows/pkgci_test_pjrt.yml b/.github/workflows/pkgci_test_pjrt.yml index 4fab7dd..461b979 100644 --- a/.github/workflows/pkgci_test_pjrt.yml +++ b/.github/workflows/pkgci_test_pjrt.yml
@@ -23,6 +23,9 @@ required: true type: string +permissions: + contents: read + jobs: build_and_test: strategy: @@ -33,6 +36,9 @@ - runner: ubuntu-24.04 pjrt_platform: cuda name: Build and test + permissions: + contents: read + actions: read # setup_venv.py --fetch-gh-workflow (dispatch with artifact_run_id). runs-on: ${{ matrix.runner }} env: PACKAGE_DOWNLOAD_DIR: ${{ github.workspace }}/.packages
diff --git a/.github/workflows/pkgci_test_riscv64.yml b/.github/workflows/pkgci_test_riscv64.yml index 85c90ea..2391ea2 100644 --- a/.github/workflows/pkgci_test_riscv64.yml +++ b/.github/workflows/pkgci_test_riscv64.yml
@@ -32,6 +32,9 @@ jobs: riscv64: + permissions: + contents: read + actions: read # setup_venv.py --fetch-gh-workflow (dispatch with artifact_run_id). runs-on: ubuntu-24.04 env: PACKAGE_DOWNLOAD_DIR: ${{ github.workspace }}/.packages @@ -99,6 +102,9 @@ run: ./build_tools/cmake/test_riscv.sh riscv64-baremetal: + permissions: + contents: read + actions: read # setup_venv.py --fetch-gh-workflow (dispatch with artifact_run_id). runs-on: ubuntu-24.04 env: PACKAGE_DOWNLOAD_DIR: ${{ github.workspace }}/.packages
diff --git a/.github/workflows/pkgci_test_sharktank.yml b/.github/workflows/pkgci_test_sharktank.yml index 4581281..e250f65 100644 --- a/.github/workflows/pkgci_test_sharktank.yml +++ b/.github/workflows/pkgci_test_sharktank.yml
@@ -17,9 +17,15 @@ type: string default: "" +permissions: + contents: read + jobs: tests: name: "sharktank_tests :: ${{ matrix.name }}" + permissions: + contents: read + actions: read # setup_venv.py --fetch-gh-workflow (dispatch with artifact_run_id). runs-on: ${{ matrix.runs-on }} strategy: fail-fast: false
diff --git a/.github/workflows/pkgci_test_tensorflow.yml b/.github/workflows/pkgci_test_tensorflow.yml index 57aafe8..39693fe 100644 --- a/.github/workflows/pkgci_test_tensorflow.yml +++ b/.github/workflows/pkgci_test_tensorflow.yml
@@ -17,9 +17,15 @@ type: string default: "" +permissions: + contents: read + jobs: linux_x86_64: name: Linux (x86_64) + permissions: + contents: read + actions: read # setup_venv.py --fetch-gh-workflow (dispatch with artifact_run_id). runs-on: ubuntu-24.04 env: PACKAGE_DOWNLOAD_DIR: ${{ github.workspace }}/.packages
diff --git a/.github/workflows/pkgci_test_torch.yml b/.github/workflows/pkgci_test_torch.yml index 828559a..3bce44c 100644 --- a/.github/workflows/pkgci_test_torch.yml +++ b/.github/workflows/pkgci_test_torch.yml
@@ -24,6 +24,9 @@ jobs: test_torch_ops: name: "test_torch_ops :: ${{ matrix.name }}" + permissions: + contents: read + actions: read # setup_venv.py --fetch-gh-workflow (dispatch with artifact_run_id). runs-on: ${{ matrix.runs-on }} strategy: fail-fast: false
diff --git a/.github/workflows/pkgci_unit_test.yml b/.github/workflows/pkgci_unit_test.yml index 562b08a..a287669 100644 --- a/.github/workflows/pkgci_unit_test.yml +++ b/.github/workflows/pkgci_unit_test.yml
@@ -17,9 +17,15 @@ type: string default: "" +permissions: + contents: read + jobs: linux_x86_64: name: Linux (x86_64) + permissions: + contents: read + actions: read # setup_venv.py --fetch-gh-workflow (dispatch with artifact_run_id). runs-on: ubuntu-24.04 env: PACKAGE_DOWNLOAD_DIR: ${{ github.workspace }}/.packages
diff --git a/.github/workflows/publish_website.yml b/.github/workflows/publish_website.yml index b100cb5..277c17d 100644 --- a/.github/workflows/publish_website.yml +++ b/.github/workflows/publish_website.yml
@@ -34,6 +34,9 @@ schedule: - cron: "0 14 * * *" +permissions: + contents: read + jobs: publish_website: if: ${{ github.repository_owner == 'iree-org' || github.event_name == 'workflow_dispatch' }} @@ -49,6 +52,7 @@ with: submodules: true token: ${{ secrets.WRITE_ACCESS_TOKEN }} + persist-credentials: false - name: Fetching base gh-pages branch # We have to explicitly fetch the gh-pages branch as well to preserve history run: git fetch --no-tags --prune --depth=1 origin "gh-pages:gh-pages" @@ -105,4 +109,8 @@ - name: Deploying to gh-pages if: ${{ github.event_name != 'release' || !contains(github.event.release.tag_name, 'rc') }} working-directory: docs/website - run: mkdocs gh-deploy + env: + GH_TOKEN: ${{ secrets.WRITE_ACCESS_TOKEN }} + run: | + git remote set-url --push origin "https://x-access-token:${GH_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" + mkdocs gh-deploy
diff --git a/.github/workflows/schedule_candidate_release.yml b/.github/workflows/schedule_candidate_release.yml index 5a4e25f..7ee7a2d 100644 --- a/.github/workflows/schedule_candidate_release.yml +++ b/.github/workflows/schedule_candidate_release.yml
@@ -12,16 +12,23 @@ required: false default: "" +permissions: + contents: read + jobs: tag_release: if: ${{ github.repository_owner == 'iree-org' || github.event_name != 'schedule' }} name: "Tag candidate release" runs-on: ubuntu-24.04 + permissions: + contents: read + actions: read # get_latest_green.sh lists ci.yml runs. steps: - name: Checking out repository uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: token: ${{ secrets.WRITE_ACCESS_TOKEN }} + persist-credentials: false fetch-depth: 0 - name: Checkout the most recent green commit @@ -62,7 +69,9 @@ git tag "${tag_name}" - name: Pushing changes - run: git push origin "${tag_name}" + env: + GH_TOKEN: ${{ secrets.WRITE_ACCESS_TOKEN }} + run: git push "https://x-access-token:${GH_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" "${tag_name}" - name: Create Release id: create_release
diff --git a/.github/workflows/setup.yml b/.github/workflows/setup.yml index 44d3508..88f3bef 100644 --- a/.github/workflows/setup.yml +++ b/.github/workflows/setup.yml
@@ -35,6 +35,9 @@ jobs: setup: runs-on: ubuntu-24.04 + permissions: + contents: read + pull-requests: read # Fetch the PR description and labels. env: # The commit being checked out is the merge commit for the PR. Its first # parent will be the tip of main.
diff --git a/.github/workflows/validate_and_publish_release.yml b/.github/workflows/validate_and_publish_release.yml index abee0ec..666f942 100644 --- a/.github/workflows/validate_and_publish_release.yml +++ b/.github/workflows/validate_and_publish_release.yml
@@ -24,6 +24,9 @@ description: "Run ID for the build_package.yml workflow that triggered this workflow" required: true +permissions: + contents: read + jobs: validate_packages: name: "Validate packages" @@ -149,6 +152,7 @@ uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: token: ${{ secrets.WRITE_ACCESS_TOKEN }} + persist-credentials: false # Get all history. Otherwise the latest-snapshot branch can't be # fast-forwarded. fetch-depth: 0
diff --git a/build_tools/scripts/get_latest_green.sh b/build_tools/scripts/get_latest_green.sh index 4242bc3..b18f34b 100755 --- a/build_tools/scripts/get_latest_green.sh +++ b/build_tools/scripts/get_latest_green.sh
@@ -41,7 +41,10 @@ local all_passing="true" for workflow in "${REQUIRED_WORKFLOWS[@]}"; do - local successful_run_count="$(\ + # Declared separately: `local x="$(cmd)"` discards cmd's exit status, so a + # failed API call (e.g. 403) would count as zero runs instead of aborting. + local successful_run_count + successful_run_count="$(\ gh api --jq '.total_count' \ "/repos/iree-org/iree/actions/workflows/${workflow}/runs?${query_string}" \ )"