|
| 1 | +--- |
| 2 | +name: adopt-upstream-pr |
| 3 | +description: 'Adopt an existing upstream PR into the philips branch. Use when: cherry-picking an open upstream PR for early deployment, bringing an existing PR branch into the fork, fast-tracking a PR that is pending upstream review.' |
| 4 | +--- |
| 5 | + |
| 6 | +# Adopt Upstream PR |
| 7 | + |
| 8 | +Bring an existing upstream PR into the `philips` branch for immediate internal use, without waiting for upstream to merge it. |
| 9 | + |
| 10 | +## When to Use |
| 11 | + |
| 12 | +- An upstream PR is open but not yet merged, and you need the change now |
| 13 | +- The PR branch already exists (on upstream, a personal fork, or the Philips fork) |
| 14 | +- You want to deploy the change internally while it continues through upstream review |
| 15 | + |
| 16 | +## Prerequisites |
| 17 | + |
| 18 | +- An open upstream PR number (e.g. `github-aws-runners/terraform-aws-github-runner#5031`) |
| 19 | +- The PR branch must be accessible (public repo or you have access) |
| 20 | + |
| 21 | +## Procedure |
| 22 | + |
| 23 | +Given an upstream PR URL like `https://github.com/github-aws-runners/terraform-aws-github-runner/pull/5031`: |
| 24 | + |
| 25 | +1. **Extract PR metadata:** |
| 26 | + ```bash |
| 27 | + # Get the PR branch, title, and head repo |
| 28 | + gh pr view 5031 --repo github-aws-runners/terraform-aws-github-runner \ |
| 29 | + --json headRefName,title,headRepository,headRepositoryOwner,commits |
| 30 | + ``` |
| 31 | + |
| 32 | +2. **Fetch the PR branch into the fork:** |
| 33 | + ```bash |
| 34 | + cd <fork-clone> |
| 35 | + git fetch origin philips |
| 36 | + git checkout philips |
| 37 | + git pull origin philips |
| 38 | + |
| 39 | + # If PR is on the same repo (upstream): |
| 40 | + git fetch upstream <branch-name> |
| 41 | + |
| 42 | + # If PR is on a personal fork (e.g. your own): |
| 43 | + git fetch https://github.com/<owner>/terraform-aws-github-runner.git <branch-name> |
| 44 | + ``` |
| 45 | + |
| 46 | +3. **Cherry-pick or rebase the PR commits onto philips:** |
| 47 | + ```bash |
| 48 | + # Option A: Single commit — cherry-pick |
| 49 | + git cherry-pick <commit-sha> |
| 50 | + |
| 51 | + # Option B: Multiple commits — cherry-pick range |
| 52 | + git cherry-pick <first-commit>^..<last-commit> |
| 53 | + |
| 54 | + # Option C: Squash into one commit |
| 55 | + git merge --squash FETCH_HEAD |
| 56 | + git commit -s -m "feat: <PR title> |
| 57 | +
|
| 58 | + Upstream-PR: github-aws-runners/terraform-aws-github-runner#<number>" |
| 59 | + ``` |
| 60 | + |
| 61 | + **The `Upstream-PR:` trailer is mandatory.** This marks the commit as temporary — it will be removed once the upstream PR is merged. |
| 62 | + |
| 63 | +4. **Verify the philips branch:** |
| 64 | + ```bash |
| 65 | + git log --oneline origin/main..philips |
| 66 | + ``` |
| 67 | + Should show infrastructure commits + the new upstream-bound commit. |
| 68 | + |
| 69 | +5. **Push:** |
| 70 | + ```bash |
| 71 | + git push origin philips --force-with-lease |
| 72 | + ``` |
| 73 | + |
| 74 | +6. **Tag a release if needed:** |
| 75 | + ```bash |
| 76 | + # Determine the base upstream version |
| 77 | + git describe --tags --abbrev=0 origin/main # e.g. v7.5.0 |
| 78 | + git tag philips-v7.5.0 philips |
| 79 | + git push origin philips-v7.5.0 |
| 80 | + ``` |
| 81 | + The release workflow triggers automatically. |
| 82 | + |
| 83 | +## Quick Reference |
| 84 | + |
| 85 | +```bash |
| 86 | +# Full one-liner for a single-commit PR from your own fork: |
| 87 | +PR_NUM=5031 |
| 88 | +PR_URL="https://github.com/github-aws-runners/terraform-aws-github-runner/pull/${PR_NUM}" |
| 89 | +BRANCH=$(gh pr view "$PR_NUM" --repo github-aws-runners/terraform-aws-github-runner --json headRefName -q .headRefName) |
| 90 | +OWNER=$(gh pr view "$PR_NUM" --repo github-aws-runners/terraform-aws-github-runner --json headRepositoryOwner -q .headRepositoryOwner.login) |
| 91 | + |
| 92 | +git checkout philips && git pull origin philips |
| 93 | +git fetch "https://github.com/${OWNER}/terraform-aws-github-runner.git" "$BRANCH" |
| 94 | +git merge --squash FETCH_HEAD |
| 95 | +git commit -s -m "feat: $(gh pr view "$PR_NUM" --repo github-aws-runners/terraform-aws-github-runner --json title -q .title) |
| 96 | +
|
| 97 | +Upstream-PR: github-aws-runners/terraform-aws-github-runner#${PR_NUM}" |
| 98 | +git push origin philips --force-with-lease |
| 99 | +``` |
| 100 | + |
| 101 | +## After Upstream Merges |
| 102 | + |
| 103 | +Once the PR lands in upstream `main`, follow the `/upstream-pr-merged` skill to drop the commit from `philips`. |
0 commit comments