Skip to content

Commit afcf178

Browse files
JOYclaude
andcommitted
fix(ci): retry gh pr create on GraphQL replica lag (not REST)
Same fix as DOScan-Frontend: the createPullRequest GraphQL mutation lags behind the REST branches endpoint. Polling REST didn't help. Retry the actual PR creation call instead, up to 6× with 5s backoff. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 03b0eaa commit afcf178

1 file changed

Lines changed: 20 additions & 18 deletions

File tree

.github/workflows/sync-upstream.yml

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -230,22 +230,12 @@ jobs:
230230
git commit -m "WIP: Merge upstream $TAG (has conflicts)" --no-verify || true
231231
git push origin "$BRANCH" --force
232232
233-
# Wait for GitHub API to register the new branch (eventual consistency).
234-
# Without this, gh pr create races and fails with:
235-
# GraphQL: ... No commits between main and BRANCH (createPullRequest)
236-
for attempt in 1 2 3 4 5 6; do
237-
if gh api "repos/${GITHUB_REPOSITORY}/branches/$BRANCH" --silent 2>/dev/null; then
238-
echo "Branch $BRANCH visible on GitHub API"
239-
break
240-
fi
241-
echo "Waiting for branch propagation (attempt $attempt)..."
242-
sleep 2
243-
done
244-
233+
# GitHub's GraphQL createPullRequest replica lags behind the REST
234+
# branches endpoint. Even after the branch is visible via REST, the
235+
# GraphQL mutation can return: "No commits between main and BRANCH".
236+
# Retry the PR creation itself with backoff.
245237
REMAINING=$(echo "${{ steps.merge.outputs.conflict_files }}" | head -20)
246-
gh pr create \
247-
--title "Sync upstream $TAG (merge conflicts)" \
248-
--body "$(cat <<EOF
238+
PR_BODY="$(cat <<EOF
249239
## Upstream Sync - $TAG
250240
251241
Auto-merge with upstream \`$TAG\` failed. Version/workflow conflicts were auto-resolved,
@@ -263,6 +253,18 @@ jobs:
263253
264254
[Upstream release notes](https://github.com/blockscout/blockscout/releases/tag/$TAG)
265255
EOF
266-
)" \
267-
--head "$BRANCH" \
268-
--base main
256+
)"
257+
for attempt in 1 2 3 4 5 6; do
258+
if gh pr create \
259+
--title "Sync upstream $TAG (merge conflicts)" \
260+
--body "$PR_BODY" \
261+
--head "$BRANCH" \
262+
--base main; then
263+
echo "PR created successfully on attempt $attempt"
264+
exit 0
265+
fi
266+
echo "gh pr create failed (attempt $attempt), retrying in 5s..."
267+
sleep 5
268+
done
269+
echo "::error::gh pr create failed after 6 attempts"
270+
exit 1

0 commit comments

Comments
 (0)