From c28319ca308dbe6058a91d7c06089f7ffdb43589 Mon Sep 17 00:00:00 2001 From: "MK (fengmk2)" Date: Fri, 13 Nov 2026 13:29:04 +0800 Subject: [PATCH] ci: keep Cloudflare credentials away from bot-authored PRs The staging deploy job excluded fork PRs and Dependabot, but not Renovate, which opens same-repository PRs here. When staging deploys are enabled, a Renovate PR would install newly published packages and actions and run them (tsx, wrangler, setup-vp) with CLOUDFLARE_API_TOKEN in the environment before anyone reviews it. The production workflow reads the same repository secret. Exclude every PR whose author is a bot account, which covers Dependabot, Renovate, and future automation, from the deploy and notify jobs, and say so in the check summary and the e2e plan. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/remote-cache-deploy.yml | 10 ++++++---- docs/e2e-plan.md | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/remote-cache-deploy.yml b/.github/workflows/remote-cache-deploy.yml index 1034f80..3bdad02 100644 --- a/.github/workflows/remote-cache-deploy.yml +++ b/.github/workflows/remote-cache-deploy.yml @@ -44,12 +44,12 @@ jobs: - name: Explain staging deployment availability if: >- always() && github.event_name == 'pull_request' && - (github.event.pull_request.head.repo.full_name != github.repository || github.event.pull_request.user.login == 'dependabot[bot]') + (github.event.pull_request.head.repo.full_name != github.repository || github.event.pull_request.user.type == 'Bot') uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9 with: script: | await core.summary.addHeading('Remote cache staging').addRaw( - 'Fork and Dependabot PRs run local checks without Cloudflare credentials. ' + + 'Fork PRs and PRs opened by bots, such as Dependabot and Renovate, run local checks without Cloudflare credentials. ' + 'A maintainer can copy the reviewed commit to an internal branch and open a PR to deploy to staging. ' + 'No live deployment passed verification for this PR.' ).write(); @@ -57,9 +57,11 @@ jobs: deploy: name: Deploy staging and run smoke tests needs: check + # Bot PRs, such as dependency updates, carry unreviewed third-party code. Keep them away from + # the Cloudflare credentials, like fork PRs. if: >- vars.REMOTE_CACHE_DEPLOY_ENABLED == 'true' && - github.event.pull_request.user.login != 'dependabot[bot]' && + github.event.pull_request.user.type != 'Bot' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) && (github.event_name != 'workflow_dispatch' || github.ref == format('refs/heads/{0}', github.event.repository.default_branch)) runs-on: ubuntu-latest @@ -115,7 +117,7 @@ jobs: name: Update PR staging verification instructions if: >- always() && github.event_name == 'pull_request' && - github.event.pull_request.head.repo.full_name == github.repository && github.event.pull_request.user.login != 'dependabot[bot]' + github.event.pull_request.head.repo.full_name == github.repository && github.event.pull_request.user.type != 'Bot' needs: [check, deploy] runs-on: ubuntu-latest timeout-minutes: 5 diff --git a/docs/e2e-plan.md b/docs/e2e-plan.md index e2efed5..3db6563 100644 --- a/docs/e2e-plan.md +++ b/docs/e2e-plan.md @@ -66,7 +66,7 @@ Set these **repository variables**, which the notification job also needs: Enable R2 in the account. The token must allow resource provisioning, updates, and fixture data access. No custom domain or DNS permission is needed. Do not attach production bindings or secrets to the staging Worker. -The workflow exposes Cloudflare credentials only to deployment and smoke-test commands. Dependency installation runs before those credentials enter the step environment. Internal PR contributors must be trusted to change deployment code. Fork and Dependabot PRs run local checks without Cloudflare credentials. Their check summary explains why staging deployment is unavailable; they receive no deployment comment. To deploy a fork change to staging, a maintainer must copy the reviewed commit to a branch in this repository and open a PR. +The workflow exposes Cloudflare credentials only to deployment and smoke-test commands. Dependency installation runs before those credentials enter the step environment. Internal PR contributors must be trusted to change deployment code. Fork PRs and PRs opened by bots, such as Dependabot and Renovate, run local checks without Cloudflare credentials, because a dependency update brings in third-party code that nobody has reviewed yet. Their check summary explains why staging deployment is unavailable; they receive no deployment comment. To deploy a fork or bot change to staging, a maintainer must copy the reviewed commit to a branch in this repository and open a PR. GitHub can suppress `pull_request` workflows when a PR has merge conflicts. Resolve the conflicts to run its checks and deployment. Manual deployment dispatches use the default branch and cannot select an arbitrary PR revision. There is no closed-PR trigger, resource teardown job, or cleanup workflow.