ci: label allowlisted fork pull requests (#2380)

This commit is contained in:
Carlos Florêncio
2026-08-07 18:24:27 +01:00
committed by GitHub
parent 5f99e0fd9d
commit fa433cc965
10 changed files with 288 additions and 7 deletions
+27
View File
@@ -73,6 +73,33 @@ jobs:
--allowedTools "mcp__github_inline_comment__create_inline_comment,Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*)"
--disallowedTools "Edit,Write,MultiEdit,NotebookEdit,WebFetch,WebSearch,Bash(git add:*),Bash(git commit:*),Bash(git push:*),Bash(git rebase:*),Bash(git reset:*),Bash(gh pr edit:*),Bash(curl:*),Bash(wget:*)"
# Mark allowlisted fork PRs with the approval labels used by the review and
# preview workflows. The direct allowlist gates remain necessary because
# labels written with GITHUB_TOKEN do not start another workflow run.
label-allowlisted-fork:
if: >
github.event_name == 'pull_request_target' &&
github.event.action == 'opened' &&
github.event.pull_request.head.repo.full_name != github.repository &&
vars.CLAUDE_REVIEW_ALLOWLIST != '' &&
contains(fromJSON(vars.CLAUDE_REVIEW_ALLOWLIST), github.event.pull_request.user.login)
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- name: Add automatic fork approval labels
uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7
with:
script: |
const labels = ['safe-to-review', 'safe-to-test'];
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
labels,
});
claude-review-fork:
# Fork PRs only, via pull_request_target so secrets are available.
# Two initial-review approval paths:
@@ -8,6 +8,7 @@ on:
- ".github/scripts/lint-action-pinning.py"
- ".github/scripts/lint-action-pinning_test.py"
- ".github/scripts/claude-code-review-workflow-contract_test.py"
- ".github/scripts/preview-env-workflow-contract_test.py"
- ".github/scripts/collect-macos-desktop-diagnostics.sh"
- ".github/scripts/release-workflow-contract_test.py"
- ".github/release-signing-key.asc"
@@ -34,6 +35,7 @@ on:
- ".github/scripts/lint-action-pinning.py"
- ".github/scripts/lint-action-pinning_test.py"
- ".github/scripts/claude-code-review-workflow-contract_test.py"
- ".github/scripts/preview-env-workflow-contract_test.py"
- ".github/scripts/collect-macos-desktop-diagnostics.sh"
- ".github/scripts/release-workflow-contract_test.py"
- ".github/release-signing-key.asc"
@@ -79,6 +81,9 @@ jobs:
- name: Test Claude Code review workflow contract
run: python3 .github/scripts/claude-code-review-workflow-contract_test.py
- name: Test preview environment workflow contract
run: python3 .github/scripts/preview-env-workflow-contract_test.py
- name: Test release workflow contract
run: python3 .github/scripts/release-workflow-contract_test.py
+9 -4
View File
@@ -68,9 +68,11 @@ jobs:
# -----------------------------------------------------------------------
# Deploy / update preview (fork PRs, gated by allowlist)
# Uses pull_request_target so secrets are available.
# Two approval paths:
# Three approval paths:
# - PREVIEW_ENV_ALLOWLIST repo variable (trusted login list, all events;
# JSON array of logins)
# - CLAUDE_REVIEW_ALLOWLIST repo variable (trusted login list, all events;
# the Claude workflow also adds the approval labels on open)
# - `safe-to-test` label (maintainer opt-in, per-commit). Explicitly
# blocked on `synchronize` so a contributor's push cannot re-use a
# stale label — the maintainer must re-apply it after each push for
@@ -87,7 +89,8 @@ jobs:
github.event_name == 'pull_request_target' &&
github.event.pull_request.head.repo.full_name != github.repository &&
((github.event.action != 'synchronize' && contains(github.event.pull_request.labels.*.name, 'safe-to-test')) ||
(vars.PREVIEW_ENV_ALLOWLIST != '' && contains(fromJSON(vars.PREVIEW_ENV_ALLOWLIST), github.event.pull_request.user.login)))
(vars.PREVIEW_ENV_ALLOWLIST != '' && contains(fromJSON(vars.PREVIEW_ENV_ALLOWLIST), github.event.pull_request.user.login)) ||
(vars.CLAUDE_REVIEW_ALLOWLIST != '' && contains(fromJSON(vars.CLAUDE_REVIEW_ALLOWLIST), github.event.pull_request.user.login)))
runs-on: ubuntu-latest
permissions:
contents: read
@@ -98,9 +101,11 @@ jobs:
with:
# pull_request_target checks out base by default; explicitly use PR head.
# Safe: the preview CLI only reads files to build artifacts and posts comments.
# NOTE: The allowlist gate (safe-to-test, PREVIEW_ENV_ALLOWLIST)
# NOTE: The allowlist gate (safe-to-test, PREVIEW_ENV_ALLOWLIST,
# CLAUDE_REVIEW_ALLOWLIST)
# authorizes running the fork's cmd/preview code with SPRITES_API_TOKEN and GH_TOKEN.
# The safe-to-test label must be re-applied after each new push (see strip-safe-to-test job).
# The safe-to-test label must be re-applied after each new push for
# the label-only path (see strip-safe-to-test job).
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.sha }}