Skip to content

Commit 04b3d23

Browse files
committed
chore: Retry labeling release PRs
1 parent 90796c0 commit 04b3d23

File tree

1 file changed

+46
-42
lines changed

1 file changed

+46
-42
lines changed

.github/workflows/release-please.yml

Lines changed: 46 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -27,47 +27,51 @@ jobs:
2727
with:
2828
github-token: ${{secrets.YOSHI_APPROVER_TOKEN}}
2929
script: |
30-
const prs = await github.pulls.list({
31-
owner: 'googleapis',
32-
repo: 'google-api-ruby-client',
33-
state: 'open',
34-
sort: 'created',
35-
direction: 'desc',
36-
per_page: 10
37-
});
38-
var found = false;
39-
prs.data.forEach(function(pr) {
40-
if (found || pr.user.login != "yoshi-code-bot" || !pr.title.startsWith("Release ")) {
41-
return;
42-
}
43-
core.info("AutoApprove: Found release PR " + pr.number);
44-
if (process.env.ENABLE_AUTO_APPROVE) {
45-
core.info("ENABLE_AUTO_APPROVE is set; labeling and approving");
46-
github.pulls.createReview({
47-
owner: 'googleapis',
48-
repo: 'google-api-ruby-client',
49-
body: "AutoApprove: Rubber stamped release!",
50-
pull_number: pr.number,
51-
event: "APPROVE"
52-
});
53-
github.issues.addLabels({
54-
owner: 'googleapis',
55-
repo: 'google-api-ruby-client',
56-
issue_number: pr.number,
57-
labels: ["autorelease: pending", "automerge", "kokoro:force-run"]
58-
});
59-
} else {
60-
core.info("ENABLE_AUTO_APPROVE is not set; labeling release only");
61-
github.issues.addLabels({
62-
owner: 'googleapis',
63-
repo: 'google-api-ruby-client',
64-
issue_number: pr.number,
65-
labels: ["autorelease: pending", "kokoro:force-run"]
66-
});
67-
}
68-
core.info("AutoApprove: complete!");
69-
found = true;
70-
});
30+
let found = false;
31+
for (let tries = 3; tries > 0; tries--) {
32+
await new Promise(r => setTimeout(r, 2000));
33+
const prs = await github.pulls.list({
34+
owner: 'googleapis',
35+
repo: 'google-api-ruby-client',
36+
state: 'open',
37+
sort: 'created',
38+
direction: 'desc',
39+
per_page: 10
40+
});
41+
prs.data.forEach(function(pr) {
42+
if (found || pr.user.login != "yoshi-code-bot" || !pr.title.startsWith("Release ")) {
43+
return;
44+
}
45+
core.info("AutoApprove: Found release PR " + pr.number);
46+
if (process.env.ENABLE_AUTO_APPROVE) {
47+
core.info("ENABLE_AUTO_APPROVE is set; labeling and approving");
48+
github.pulls.createReview({
49+
owner: 'googleapis',
50+
repo: 'google-api-ruby-client',
51+
body: "AutoApprove: Rubber stamped release!",
52+
pull_number: pr.number,
53+
event: "APPROVE"
54+
});
55+
github.issues.addLabels({
56+
owner: 'googleapis',
57+
repo: 'google-api-ruby-client',
58+
issue_number: pr.number,
59+
labels: ["autorelease: pending", "automerge", "kokoro:force-run"]
60+
});
61+
} else {
62+
core.info("ENABLE_AUTO_APPROVE is not set; labeling release only");
63+
github.issues.addLabels({
64+
owner: 'googleapis',
65+
repo: 'google-api-ruby-client',
66+
issue_number: pr.number,
67+
labels: ["autorelease: pending", "kokoro:force-run"]
68+
});
69+
}
70+
core.info("AutoApprove: complete!");
71+
found = true;
72+
tries = 0;
73+
});
74+
}
7175
if (!found) {
72-
core.setFailed("Unable to find release PR.");
76+
core.setFailed("Unable to find release PR after 3 tries.");
7377
}

0 commit comments

Comments
 (0)