Skip to content

Commit 208143e

Browse files
holly-cumminsclaude
andcommitted
Use GitHub API to get PR commits for cherry-pick
Instead of computing the revision range between the sync target branch and the PR head (which includes unrelated commits from the base branch), use the GitHub API to get only the commits that belong to the PR. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 3eb0eb6 commit 208143e

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

.github/workflows/syncbot.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ jobs:
2626
id: cherry-pick
2727
env:
2828
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
29+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2930
run: |
3031
git config user.name syncbot
3132
git config user.email github-actions@github.com
@@ -36,7 +37,6 @@ jobs:
3637
3738
# Get the source branch name and target branch
3839
SOURCE_BRANCH="${{ github.head_ref }}"
39-
SOURCE_SHA="${{ github.event.pull_request.head.sha }}"
4040
TARGET_BRANCH="${{ steps.target-branch.outputs.branch }}"
4141
SYNC_BRANCH="sync-${SOURCE_BRANCH}-to-${TARGET_BRANCH}"
4242
@@ -55,8 +55,8 @@ jobs:
5555
# Create sync branch from target branch (will reset if remote exists)
5656
git checkout -b $SYNC_BRANCH origin/$TARGET_BRANCH
5757
58-
# Get all commits from the PR
59-
COMMITS=$(git log --reverse --format="%H" origin/$TARGET_BRANCH..$SOURCE_SHA)
58+
# Get only the commits that are part of the PR
59+
COMMITS=$(gh api repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/commits --jq '.[].sha')
6060
6161
# Cherry-pick each commit
6262
echo "Cherry-picking commits..."

0 commit comments

Comments
 (0)