Skip to content

Commit 4ebaf41

Browse files
committed
Drop pr-snapshot job
1 parent 08f5d47 commit 4ebaf41

2 files changed

Lines changed: 10 additions & 71 deletions

File tree

.github/scripts/pr-triage/README.md

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,10 @@ holds a privileged token AND executes PR-controlled code.
1212
| Job | Entry point | Tokens visible | PR-controlled code allowed |
1313
| ---------------- | -------------------- | --------------------------------------------- | -------------------------- |
1414
| authorize-command| `authorize.py` | `GITHUB_TOKEN` | none (default-branch checkout only) |
15-
| pr-snapshot | inline | `GITHUB_TOKEN` | none — `gh pr checkout` + `git bundle`; PR tree never executed |
1615
| gradle-worker | `worker_gradle.py` | `GITHUB_TOKEN` | yes — runs `./gradlew` on PR tree |
1716
| copilot-worker | `worker_copilot.py` | `GITHUB_TOKEN`, `COPILOT_GITHUB_TOKEN` | only Copilot CLI editing files; never `./gradlew` or other build tools |
1817
| poster | `poster.py` | otelbot installation token | none — `git`/`gh` on the worker artifact only |
1918

20-
The PR working tree is checked out exactly once, in `pr-snapshot`, which
21-
holds no privileged secrets. It is exported as a git bundle and consumed
22-
by the worker jobs via `git fetch <bundle-file>`. This keeps `gh pr
23-
checkout` (which CodeQL flags as untrusted) out of any job that holds
24-
the Copilot token.
25-
2619
Invariants (see the comments at the top of each entry-point file):
2720

2821
* `gradle-worker` must never receive `COPILOT_GITHUB_TOKEN` or any other

.github/workflows/pr-triage-comments.yml

Lines changed: 10 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -32,45 +32,6 @@ jobs:
3232
GH_TOKEN: ${{ github.token }}
3333
run: python3 .github/scripts/pr-triage/authorize.py
3434

35-
# pr-snapshot is the ONLY job that runs `gh pr checkout`. It has no
36-
# secrets and only `contents: read`, so the untrusted PR ref is never
37-
# combined with a privileged token. The PR tree is exported as a git
38-
# bundle and consumed by the worker jobs via `git fetch <file>`, which
39-
# CodeQL does not classify as an untrusted checkout.
40-
pr-snapshot:
41-
needs: authorize-command
42-
if: |
43-
needs.authorize-command.outputs.allowed == 'true' &&
44-
contains(fromJSON('["spotless","update_branch","fix","review"]'), needs.authorize-command.outputs.command)
45-
runs-on: ubuntu-latest
46-
permissions:
47-
contents: read
48-
env:
49-
PR_NUMBER: ${{ github.event.issue.number }}
50-
steps:
51-
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
52-
with:
53-
fetch-depth: 0
54-
55-
- name: Bundle PR working tree
56-
env:
57-
GH_TOKEN: ${{ github.token }}
58-
run: |
59-
gh pr checkout "$PR_NUMBER"
60-
mkdir -p "$RUNNER_TEMP/snapshot"
61-
# --all so worker jobs see both the PR head and the base
62-
# branch (needed by /update-branch). The bundle is consumed
63-
# by `git fetch <file>` in the worker jobs; nothing in the
64-
# PR tree is executed in this job.
65-
git bundle create "$RUNNER_TEMP/snapshot/pr.bundle" --all
66-
git rev-parse HEAD > "$RUNNER_TEMP/snapshot/head.txt"
67-
68-
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
69-
with:
70-
name: pr-tree-bundle
71-
path: ${{ runner.temp }}/snapshot
72-
retention-days: 1
73-
7435
# gradle-worker runs the PR triage commands that need Gradle on the PR's
7536
# working tree (/spotless, /update-branch, and the deterministic phase of
7637
# /fix). It does NOT receive the Copilot token, so a malicious build cannot
@@ -81,7 +42,7 @@ jobs:
8142
# commits and bundles. Otherwise it writes a CI bundle to handoff to
8243
# copilot-worker and signals needs-copilot=true.
8344
gradle-worker:
84-
needs: [authorize-command, pr-snapshot]
45+
needs: authorize-command
8546
if: |
8647
needs.authorize-command.outputs.allowed == 'true' &&
8748
contains(fromJSON('["spotless","update_branch","fix"]'), needs.authorize-command.outputs.command)
@@ -102,17 +63,10 @@ jobs:
10263
mkdir -p "$RUNNER_TEMP/pr-triage-trusted"
10364
cp -r .github/scripts/pr-triage/. "$RUNNER_TEMP/pr-triage-trusted/"
10465
105-
- name: Download PR bundle
106-
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
107-
with:
108-
name: pr-tree-bundle
109-
path: ${{ runner.temp }}/pr-snapshot
110-
111-
- name: Restore PR working tree from bundle
112-
run: |
113-
HEAD_SHA=$(cat "$RUNNER_TEMP/pr-snapshot/head.txt")
114-
git fetch "$RUNNER_TEMP/pr-snapshot/pr.bundle" "+$HEAD_SHA:refs/pr-triage/head"
115-
git checkout --detach "refs/pr-triage/head"
66+
- name: Check out PR
67+
env:
68+
GH_TOKEN: ${{ github.token }}
69+
run: gh pr checkout "$PR_NUMBER"
11670

11771
- name: Set up JDK for running Gradle
11872
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
@@ -155,11 +109,10 @@ jobs:
155109
# PR-controlled build tooling, so the Copilot token is never reachable
156110
# by code from the PR working tree.
157111
copilot-worker:
158-
needs: [authorize-command, pr-snapshot, gradle-worker]
112+
needs: [authorize-command, gradle-worker]
159113
if: |
160114
always() &&
161115
needs.authorize-command.outputs.allowed == 'true' &&
162-
needs.pr-snapshot.result == 'success' &&
163116
(needs.authorize-command.outputs.command == 'review' ||
164117
(needs.authorize-command.outputs.command == 'fix' && needs.gradle-worker.outputs.needs-copilot == 'true'))
165118
runs-on: ubuntu-latest
@@ -177,17 +130,10 @@ jobs:
177130
mkdir -p "$RUNNER_TEMP/pr-triage-trusted"
178131
cp -r .github/scripts/pr-triage/. "$RUNNER_TEMP/pr-triage-trusted/"
179132
180-
- name: Download PR bundle
181-
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
182-
with:
183-
name: pr-tree-bundle
184-
path: ${{ runner.temp }}/pr-snapshot
185-
186-
- name: Restore PR working tree from bundle
187-
run: |
188-
HEAD_SHA=$(cat "$RUNNER_TEMP/pr-snapshot/head.txt")
189-
git fetch "$RUNNER_TEMP/pr-snapshot/pr.bundle" "+$HEAD_SHA:refs/pr-triage/head"
190-
git checkout --detach "refs/pr-triage/head"
133+
- name: Check out PR
134+
env:
135+
GH_TOKEN: ${{ github.token }}
136+
run: gh pr checkout "$PR_NUMBER"
191137

192138
- name: Install Copilot CLI
193139
run: npm install -g @github/copilot@1.0.40

0 commit comments

Comments
 (0)