From d71aa9b305c5a7300fb2910abf26837ab84cc2a1 Mon Sep 17 00:00:00 2001 From: Kyle Carberry Date: Fri, 20 Nov 2026 15:22:31 -0500 Subject: [PATCH 1/2] ci: open the update and Helm/changelog PRs as coder-automations The org doesn't let GITHUB_TOKEN create pull requests, so publish.yaml's repo job failed to open the v4.146.0 Helm/changelog PR, and update.yaml will fail to open the next "Update Code to X" PR. Both jobs now check out without persisted credentials, run their update script, then mint a coder-automations token (Cloud KMS) for coder/code-server only, and push and open the PR with it. update.yaml runs in the new main-only update environment; the repo job in release. GITHUB_TOKEN drops to contents: read. PRs opened by the App also trigger CI, which GITHUB_TOKEN-created ones didn't. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/publish.yaml | 27 ++++++++++++++++++++++++--- .github/workflows/update.yaml | 27 ++++++++++++++++++++++++--- 2 files changed, 48 insertions(+), 6 deletions(-) diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index e8449e368953..6300a33e403f 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -233,11 +233,15 @@ jobs: - run: ./ci/steps/docker-buildx-push.sh + # The org doesn't let GITHUB_TOKEN open pull requests, so the branch is pushed and the PR opened + # as the coder-automations App (installed on coder/code-server; its key signs only for + # publish.yaml in the release environment). repo: runs-on: ubuntu-latest + environment: release permissions: - contents: write # To push the branch. - pull-requests: write # To open the PR. + contents: read + id-token: write # Cloud KMS signs the coder-automations App's JWT env: TAG: ${{ inputs.version || github.ref_name }} needs: docker @@ -253,13 +257,30 @@ jobs: echo "VERSION=${TAG#v}" >> "$GITHUB_ENV" - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6 + with: + persist-credentials: false - run: ./ci/build/update-repo.sh + # Minted after the update script so the token only exists for the push and the PR. + - name: Generate coder-automations app token + id: app_token + uses: coder/github-app-token-action@00eaec58ee1bfea9c8b48655b7ab7470b07739e5 # main 2026-11-17 + with: + client-id: ${{ secrets.CODER_AUTOMATION_APP_ID }} + kms-key: ${{ secrets.CODER_AUTOMATION_APP_KMS_KEY }} + workload-identity-provider: ${{ secrets.APP_KEYS_WORKLOAD_ID_PROVIDER }} + owner: coder + repositories: code-server + permissions: | + contents: write + pull_requests: write + - name: Open PR env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_TOKEN: ${{ steps.app_token.outputs.token }} run: | + gh auth setup-git git config --global user.name cdrci git config --global user.email opensource@coder.com git checkout -b "helm/$VERSION" diff --git a/.github/workflows/update.yaml b/.github/workflows/update.yaml index 7d2a6a950837..869a40fd967f 100644 --- a/.github/workflows/update.yaml +++ b/.github/workflows/update.yaml @@ -10,11 +10,15 @@ on: - cron: "0 16,21 * * *" jobs: + # The org doesn't let GITHUB_TOKEN open pull requests, so the branch is pushed and the PR opened + # as the coder-automations App. Its key signs only for this file on main, in the update + # environment (main only). update: runs-on: ubuntu-latest + environment: update permissions: - contents: write # To push the branch. - pull-requests: write # To open the PR. + contents: read + id-token: write # Cloud KMS signs the coder-automations App's JWT env: TAG: ${{ inputs.version }} @@ -33,6 +37,7 @@ jobs: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6 with: submodules: true + persist-credentials: false - name: Check current version id: check @@ -58,11 +63,27 @@ jobs: - run: ./ci/build/update-vscode.sh if: steps.check.outputs.done == 'false' + # Minted after the update script so the token only exists for the push and the PR. + - name: Generate coder-automations app token + id: app_token + if: steps.check.outputs.done == 'false' + uses: coder/github-app-token-action@00eaec58ee1bfea9c8b48655b7ab7470b07739e5 # main 2026-11-17 + with: + client-id: ${{ secrets.CODER_AUTOMATION_APP_ID }} + kms-key: ${{ secrets.CODER_AUTOMATION_APP_KMS_KEY }} + workload-identity-provider: ${{ secrets.APP_KEYS_WORKLOAD_ID_PROVIDER }} + owner: coder + repositories: code-server + permissions: | + contents: write + pull_requests: write + - name: Open PR if: steps.check.outputs.done == 'false' env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_TOKEN: ${{ steps.app_token.outputs.token }} run: | + gh auth setup-git git config --global user.name cdrci git config --global user.email opensource@coder.com git checkout -b "update/$VERSION" From 5e1c0501f83b74eab0248172fbef16549dde3a96 Mon Sep 17 00:00:00 2001 From: Kyle Carberry Date: Fri, 20 Nov 2026 15:27:13 -0500 Subject: [PATCH 2/2] ci(publish): no dependency cache in the npm publish job setup-node caches the package manager's store by default, so a cache saved by another run could reach the job that publishes to npm. Turn it off there (zizmor cache-poisoning). Co-Authored-By: Claude Opus 5.5 --- .github/workflows/publish.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 6300a33e403f..ab36dc68f7a3 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -86,6 +86,9 @@ jobs: with: node-version-file: .node-version registry-url: "https://registry.npmjs.org" + # No dependency cache in a job that publishes: a cache saved by another run could + # change what gets published. + package-manager-cache: false - uses: robinraju/release-downloader@28fc21f50d76778e7023361aa1f863e717d3d56f # v1.13 with: