Skip to content

Commit f4b6bbb

Browse files
authored
fix: Wait for PR toolkit to finish before attempting merge of PR to develop (#109)
1 parent 76da0a9 commit f4b6bbb

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

.github/workflows/sync_branches.yaml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,37 @@ jobs:
8080
event: 'APPROVE',
8181
})
8282
83+
// Wait for PR toolkit to finish (up to 3 minutes) on the pull request
84+
let i = 0;
85+
let prToolkitSuccessful = false;
86+
while (i++ < 60) {
87+
const resp = await github.rest.checks.listForRef({
88+
owner: context.repo.owner,
89+
repo: context.repo.repo,
90+
ref: `pull/${pullRequestNumber}/head`,
91+
check_name: 'apify-pr-toolkit',
92+
});
93+
94+
if (resp.data.check_runs.length > 1) {
95+
throw new Error('There are more than one PR toolkit runs, this should be impossible');
96+
}
97+
98+
if (resp.data.check_runs.length === 1 && resp.data.check_runs[0].status === 'completed') {
99+
if (resp.data.check_runs[0].conclusion === 'success') {
100+
console.log('PR toolkit succeeded');
101+
prToolkitSuccessful = true;
102+
break;
103+
} else {
104+
throw new Error('PR toolkit failed');
105+
}
106+
}
107+
108+
await new Promise((resolve) => setTimeout(resolve, 3000));
109+
}
110+
if (!prToolkitSuccessful) {
111+
throw new Error('PR toolkit check did not finish in time');
112+
}
113+
83114
// Merge pull request
84115
await github.rest.pulls.merge({
85116
owner: context.repo.owner,

0 commit comments

Comments
 (0)