Skip to content

Commit b04f3e5

Browse files
authored
[ci] Compares commits before creating a sync PR to sync release branch back to the main branch. (flutter#11398)
fix the error: `pull request create failed: GraphQL: No commits between main and release-go_router (createPullRequest) ` from https://github.com/flutter/packages/actions/runs/23563276945/job/68608396579 ## Pre-Review Checklist **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. [^1]: Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling.
1 parent 1de9829 commit b04f3e5

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

‎.github/workflows/sync_release_pr.yml‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: "Sync Release to Main"
33
on:
44
push:
55
branches:
6-
# As packages opt into batched releases, they need to be added here
6+
# As packages opt into batched releases, they need to be added here
77
- 'release-go_router'
88

99
jobs:
@@ -16,11 +16,26 @@ jobs:
1616
steps:
1717
- name: Checkout repository
1818
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
19+
with:
20+
fetch-depth: 0 # Fetch history to allow branch comparison
1921

2022
- name: Create Pull Request
2123
env:
2224
GITHUB_TOKEN: ${{ secrets.FLUTTERGITHUBBOT_TOKEN }}
2325
run: |
26+
# 1. Fetch main so the runner can see the difference
27+
git fetch origin main
28+
29+
# 2. Verify there are actually new commits to sync
30+
# This prevents the "GraphQL: No commits between main..." error
31+
COMMITS_COUNT=$(git rev-list --count origin/main..HEAD)
32+
33+
if [ "$COMMITS_COUNT" -eq "0" ]; then
34+
echo "No new commits found on ${{ github.ref_name }} compared to main. Nothing to sync."
35+
exit 0
36+
fi
37+
38+
# 3. Create the PR directly
2439
gh pr create \
2540
--base "main" \
2641
--head "${{ github.ref_name }}" \

0 commit comments

Comments
 (0)