Skip to content

Commit e70c69b

Browse files
authored
Update auto-merge.yml
1 parent 828895c commit e70c69b

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

.github/workflows/auto-merge.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,46 @@ jobs:
5454
core.setOutput("shouldMerge", "true");
5555
result-encoding: string
5656

57+
- name: Wait for checks to pass
58+
if: steps.check.outputs.shouldMerge == 'true'
59+
uses: actions/github-script@v6
60+
with:
61+
script: |
62+
const prNumber = context.payload.pull_request.number;
63+
const { data: pr } = await github.rest.pulls.get({
64+
owner: context.repo.owner,
65+
repo: context.repo.repo,
66+
pull_number: prNumber
67+
});
68+
69+
// Wait for status checks to pass.
70+
let checksPending = true;
71+
let retries = 0;
72+
const maxRetries = 20;
73+
const waitTime = 30000;
74+
75+
while (checksPending && retries < maxRetries) {
76+
const { data: combinedStatus } = await github.rest.repos.getCombinedStatusForRef({
77+
owner: context.repo.owner,
78+
repo: context.repo.repo,
79+
ref: pr.head.sha
80+
});
81+
82+
if (combinedStatus.state === 'success') {
83+
checksPending = false;
84+
} else {
85+
core.info(`Checks still pending. Waiting... (${retries + 1}/${maxRetries})`);
86+
await new Promise(resolve => setTimeout(resolve, waitTime));
87+
retries++;
88+
}
89+
}
90+
91+
if (checksPending) {
92+
throw new Error("Checks did not complete successfully within the time limit.");
93+
}
94+
95+
core.info("All checks passed.");
96+
5797
- name: Auto-Merge PR
5898
if: steps.check.outputs.shouldMerge == 'true'
5999
uses: actions/github-script@v6

0 commit comments

Comments
 (0)