From 717f623b7409d13a40b3c8184de6bbda7065f020 Mon Sep 17 00:00:00 2001 From: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com> Date: Wed, 25 Nov 2026 09:16:02 -0600 Subject: [PATCH] pin third-party actions and scope workflow tokens (#25094) easimon/maximize-build-space ran from a branch, and the lowercase and manifest actions ran from mutable tags, inside jobs that push images and mint build attestations. The release workflow also ran skopeo from its latest tag with the push credential mounted. The actions are now pinned to commit SHAs with version comments so Dependabot still bumps them, the lowercase action is replaced with ${GITHUB_REPOSITORY,,}, and skopeo is pinned by digest. ci.yml, release.yml, pull_request.yml and stale.yml now declare explicit token permissions instead of relying on the repository default. --- .github/actions/setup/action.yml | 7 +++---- .github/workflows/ci.yml | 15 +++++++++++---- .github/workflows/pull_request.yml | 3 +++ .github/workflows/release.yml | 18 +++++++++++------- .github/workflows/stale.yml | 7 ++++++- 5 files changed, 34 insertions(+), 16 deletions(-) diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index 98d564c8f5..0777665b53 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -23,7 +23,7 @@ runs: # from root and temp-reserve-mb is what actually stays free on root. Keep 4G # there for setup-qemu/buildx caches in ~/.docker and the tool cache - name: Maximize build space - uses: easimon/maximize-build-space@master + uses: easimon/maximize-build-space@fc881a613ad2a34aca9c9624518214ebc21dfc0c # v10 with: root-reserve-mb: 8192 temp-reserve-mb: 4096 @@ -36,9 +36,8 @@ runs: run: sudo systemctl start docker shell: bash - id: lowercaseRepo - uses: ASzc/change-string-case-action@v8 - with: - string: ${{ github.repository }} + run: echo "lowercase=${GITHUB_REPOSITORY,,}" >> $GITHUB_OUTPUT + shell: bash - name: Set up QEMU uses: docker/setup-qemu-action@v4 - name: Set up Docker Buildx diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ddcdc28c0d..9682eeb34f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,6 +14,9 @@ concurrency: group: ${{ github.ref }} cancel-in-progress: true +permissions: + contents: read + env: PYTHON_VERSION: 3.11 @@ -21,6 +24,9 @@ jobs: amd64_build: runs-on: ubuntu-22.04 name: AMD64 Build + permissions: + contents: read + packages: write steps: - name: Check out code uses: actions/checkout@v7 @@ -45,6 +51,9 @@ jobs: smoke_test: runs-on: ubuntu-22.04 name: AMD64 Smoke Test + permissions: + contents: read + packages: read needs: - amd64_build steps: @@ -675,9 +684,7 @@ jobs: - arm64_build steps: - id: lowercaseRepo - uses: ASzc/change-string-case-action@v8 - with: - string: ${{ github.repository }} + run: echo "lowercase=${GITHUB_REPOSITORY,,}" >> $GITHUB_OUTPUT - name: Log in to the Container registry uses: docker/login-action@8aa5831fb8d48d8f76594c7ddde61ae58019f550 with: @@ -686,7 +693,7 @@ jobs: password: ${{ secrets.GITHUB_TOKEN }} - name: Create short sha run: echo "SHORT_SHA=${GITHUB_SHA::7}" >> $GITHUB_ENV - - uses: int128/docker-manifest-create-action@v2 + - uses: int128/docker-manifest-create-action@d6ac360314337bbfb870747d9616b83118acb330 # v2.30.0 id: manifest with: tags: ghcr.io/${{ steps.lowercaseRepo.outputs.lowercase }}:${{ env.SHORT_SHA }} diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index a279686700..e9330aa494 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -8,6 +8,9 @@ on: - ".github/DISCUSSION_TEMPLATE/**" - ".github/ISSUE_TEMPLATE/**" +permissions: + contents: read + env: DEFAULT_PYTHON: 3.11 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d2a33dd9a3..15088e64fc 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -5,6 +5,10 @@ on: release: types: [published] +permissions: + contents: read + packages: write + jobs: release: runs-on: ubuntu-latest @@ -14,9 +18,7 @@ jobs: with: persist-credentials: false - id: lowercaseRepo - uses: ASzc/change-string-case-action@v8 - with: - string: ${{ github.repository }} + run: echo "lowercase=${GITHUB_REPOSITORY,,}" >> $GITHUB_OUTPUT - name: Log in to the Container registry uses: docker/login-action@8aa5831fb8d48d8f76594c7ddde61ae58019f550 with: @@ -34,19 +36,21 @@ jobs: echo "BUILD_TAG=${GITHUB_SHA::7}" >> $GITHUB_ENV echo "CLEAN_VERSION=$(echo ${GITHUB_REF##*/} | tr '[:upper:]' '[:lower:]' | sed 's/^[v]//')" >> $GITHUB_ENV - name: Tag and push the main image + env: + SKOPEO: quay.io/skopeo/stable:v1.24.1-immutable@sha256:81a8d4265c339539cba229459fdc4cb3580e1d2c2cb4285271c75adaa0fcb9b5 run: | VERSION_TAG=${BASE}:${CLEAN_VERSION} STABLE_TAG=${BASE}:stable PULL_TAG=${BASE}:${BUILD_TAG} - docker run --rm -v $HOME/.docker/config.json:/config.json quay.io/skopeo/stable:latest copy --authfile /config.json --multi-arch all docker://${PULL_TAG} docker://${VERSION_TAG} + docker run --rm -v $HOME/.docker/config.json:/config.json ${SKOPEO} copy --authfile /config.json --multi-arch all docker://${PULL_TAG} docker://${VERSION_TAG} for variant in standard-arm64 tensorrt tensorrt-jp6 rk rocm synaptics; do - docker run --rm -v $HOME/.docker/config.json:/config.json quay.io/skopeo/stable:latest copy --authfile /config.json --multi-arch all docker://${PULL_TAG}-${variant} docker://${VERSION_TAG}-${variant} + docker run --rm -v $HOME/.docker/config.json:/config.json ${SKOPEO} copy --authfile /config.json --multi-arch all docker://${PULL_TAG}-${variant} docker://${VERSION_TAG}-${variant} done # stable tag if [[ "${BUILD_TYPE}" == "stable" ]]; then - docker run --rm -v $HOME/.docker/config.json:/config.json quay.io/skopeo/stable:latest copy --authfile /config.json --multi-arch all docker://${PULL_TAG} docker://${STABLE_TAG} + docker run --rm -v $HOME/.docker/config.json:/config.json ${SKOPEO} copy --authfile /config.json --multi-arch all docker://${PULL_TAG} docker://${STABLE_TAG} for variant in standard-arm64 tensorrt tensorrt-jp6 rk rocm synaptics; do - docker run --rm -v $HOME/.docker/config.json:/config.json quay.io/skopeo/stable:latest copy --authfile /config.json --multi-arch all docker://${PULL_TAG}-${variant} docker://${STABLE_TAG}-${variant} + docker run --rm -v $HOME/.docker/config.json:/config.json ${SKOPEO} copy --authfile /config.json --multi-arch all docker://${PULL_TAG}-${variant} docker://${STABLE_TAG}-${variant} done fi diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index 39512f24a3..8add095a31 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -7,11 +7,16 @@ on: schedule: - cron: "0 0 * * *" # run stalebot once a day +permissions: + actions: write + issues: write + pull-requests: write + jobs: stale: runs-on: ubuntu-latest steps: - - uses: actions/stale@main + - uses: actions/stale@4391f3da665fdf50b6810c1a66712fb9ba21aa93 # v11.0.0 id: stale with: stale-issue-message: "This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions."