Skip to content

Commit 4b71374

Browse files
authored
[STG-1518] Add Github Action that allows claiming external contributor PRs to run CI with secrets (browserbase#1794)
# why - External contributor PRs currently fail CI because they cant run with secrets - We dont want to allow them to run with secrets until a team member "claims" them and reviews for any secrets exfiltration / sketchy code - Once claimed, we want to run the full CI suite with secrets # what changed # test plan <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Adds two GitHub Actions that let maintainers claim external contributor PRs by mirroring the approved head SHA to a maintainer-owned branch so full CI can run with secrets. Claims come from an approving review by a team member with write access on the latest commit and are auto-invalidated on new commits (Linear STG-1518). - **New Features** - Detects forked PRs and posts claim instructions; manages labels: `external-contributor`, `external-contributor:awaiting-approval`, `external-contributor:mirrored`, `external-contributor:stale`, `external-contributor:completed`. - On approving review of the latest commit, verifies reviewer permission, mirrors that exact SHA to `external-contributor-pr-<PR#>-<12sha>`, and creates/reopens a “[Claimed #X]” PR assigned to the approver. - Closes and links the original PR with marker comments; keeps labels/status in sync on both PRs. - Auto-closes the mirror when new commits land on the external PR and comments with next steps; if the mirror closes without merge, reopens and relabels the original PR; if the external PR is reopened with the same approved SHA while the mirror is open, it is closed again to keep discussion on the mirror. - Implemented via `external-contributor-pr-approval-handoff.yml` (captures approved reviews, uploads artifact) and `external-contributor-pr.yml` (consumes artifact, performs mirroring); uses `actions/github-script@v7`, `actions/create-github-app-token@v1`, `actions/checkout@v4`, `actions/download-artifact@v4`, `actions/upload-artifact@v4`; concurrency scoped per PR/workflow run. - **Migration** - Create a GitHub App with `contents:write`, `pull_requests:write`, and `issues:write`; add `EXTERNAL_CONTRIBUTOR_PR_APP_ID` and `EXTERNAL_CONTRIBUTOR_PR_APP_PRIVATE_KEY` secrets. - To claim: submit an approving review on the latest commit of a forked PR. If new commits are pushed, approve again to re-claim and rerun CI. <sup>Written for commit 4875e99. Summary will update on new commits. <a href="https://cubic.dev/pr/browserbase/stagehand/pull/1794">Review in cubic</a></sup> <!-- End of auto-generated description by cubic. -->
1 parent c85222c commit 4b71374

2 files changed

Lines changed: 932 additions & 0 deletions

File tree

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: External Contributor PR Approval Handoff
2+
3+
on:
4+
pull_request_review:
5+
types:
6+
- submitted
7+
8+
permissions:
9+
contents: read
10+
pull-requests: read
11+
12+
jobs:
13+
capture-approved-review:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Write approval handoff payload
17+
uses: actions/github-script@v7
18+
with:
19+
github-token: ${{ secrets.GITHUB_TOKEN }}
20+
script: |
21+
const fs = require('fs');
22+
const pr = context.payload.pull_request;
23+
const review = context.payload.review;
24+
const shouldClaim =
25+
review.state === 'approved' &&
26+
pr.head.repo.full_name !== context.payload.repository.full_name;
27+
28+
const payload = {
29+
shouldClaim,
30+
prNumber: pr.number,
31+
reviewer: review.user?.login || '',
32+
reviewId: review.id,
33+
approvedSha: review.commit_id || pr.head.sha,
34+
};
35+
36+
fs.writeFileSync('approval-handoff.json', JSON.stringify(payload));
37+
38+
- name: Upload approval handoff artifact
39+
uses: actions/upload-artifact@v4
40+
with:
41+
name: approved-review
42+
path: approval-handoff.json
43+
retention-days: 1

0 commit comments

Comments
 (0)