Skip to content

Commit eaa203e

Browse files
authored
Apply a delay before we enable auto merge on a PR (#992)
We saw the auto merging workflow (added in #988) failed in https://github.com/mmtk/mmtk-core/actions/runs/6587030083/job/17896533403. The error message was `GraphQL: Head branch is out of date. Review and try the merge again. (mergePullRequest)`. It is likely caused by the issue https://github.com/orgs/community/discussions/24462: When a PR gets updated, Github has a process to determine if the PR is mergable. If we attempt to enable auto merge before the process is done, the merge will fail with the error message above. This PR adds a delay and retry for enabling auto merging.
1 parent 06a2e5d commit eaa203e

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

.github/workflows/auto-merge-inner.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,15 @@ jobs:
8787
git commit -m "Update mmtk-core to ${{ inputs.core_commit }}"
8888
git push
8989
90+
# Apply a delay before we attempt to merge and retry if we fail: there is a small period of time that we cannot merge a PR after we update it.
9091
- name: Enable auto-merge for the PR
9192
if: steps.check-input.outputs.skip == 'false'
9293
run: |
93-
gh pr merge ${{ steps.get-pr.outputs.pr_number }} --auto --repo ${{ inputs.base_repo }} --squash
94+
for n in {1..5}; do
95+
echo "Wait 30s then try merge"
96+
sleep 30
97+
gh pr merge ${{ steps.get-pr.outputs.pr_number }} --auto --repo ${{ inputs.base_repo }} --squash && break
98+
echo "Failed to merge the PR. Retry..."
99+
done
94100
env:
95101
GITHUB_TOKEN: ${{ secrets.CI_ACCESS_TOKEN }}

0 commit comments

Comments
 (0)