chore: Retry labeling release PRs

This commit is contained in:
Daniel Azuma 2020-11-02 21:16:35 +00:00
parent 90796c08c0
commit 04b3d2328c
1 changed files with 47 additions and 43 deletions

View File

@ -27,47 +27,51 @@ jobs:
with: with:
github-token: ${{secrets.YOSHI_APPROVER_TOKEN}} github-token: ${{secrets.YOSHI_APPROVER_TOKEN}}
script: | script: |
const prs = await github.pulls.list({ let found = false;
owner: 'googleapis', for (let tries = 3; tries > 0; tries--) {
repo: 'google-api-ruby-client', await new Promise(r => setTimeout(r, 2000));
state: 'open', const prs = await github.pulls.list({
sort: 'created', owner: 'googleapis',
direction: 'desc', repo: 'google-api-ruby-client',
per_page: 10 state: 'open',
}); sort: 'created',
var found = false; direction: 'desc',
prs.data.forEach(function(pr) { per_page: 10
if (found || pr.user.login != "yoshi-code-bot" || !pr.title.startsWith("Release ")) { });
return; prs.data.forEach(function(pr) {
} if (found || pr.user.login != "yoshi-code-bot" || !pr.title.startsWith("Release ")) {
core.info("AutoApprove: Found release PR " + pr.number); return;
if (process.env.ENABLE_AUTO_APPROVE) { }
core.info("ENABLE_AUTO_APPROVE is set; labeling and approving"); core.info("AutoApprove: Found release PR " + pr.number);
github.pulls.createReview({ if (process.env.ENABLE_AUTO_APPROVE) {
owner: 'googleapis', core.info("ENABLE_AUTO_APPROVE is set; labeling and approving");
repo: 'google-api-ruby-client', github.pulls.createReview({
body: "AutoApprove: Rubber stamped release!", owner: 'googleapis',
pull_number: pr.number, repo: 'google-api-ruby-client',
event: "APPROVE" body: "AutoApprove: Rubber stamped release!",
}); pull_number: pr.number,
github.issues.addLabels({ event: "APPROVE"
owner: 'googleapis', });
repo: 'google-api-ruby-client', github.issues.addLabels({
issue_number: pr.number, owner: 'googleapis',
labels: ["autorelease: pending", "automerge", "kokoro:force-run"] repo: 'google-api-ruby-client',
}); issue_number: pr.number,
} else { labels: ["autorelease: pending", "automerge", "kokoro:force-run"]
core.info("ENABLE_AUTO_APPROVE is not set; labeling release only"); });
github.issues.addLabels({ } else {
owner: 'googleapis', core.info("ENABLE_AUTO_APPROVE is not set; labeling release only");
repo: 'google-api-ruby-client', github.issues.addLabels({
issue_number: pr.number, owner: 'googleapis',
labels: ["autorelease: pending", "kokoro:force-run"] repo: 'google-api-ruby-client',
}); issue_number: pr.number,
} labels: ["autorelease: pending", "kokoro:force-run"]
core.info("AutoApprove: complete!"); });
found = true; }
}); core.info("AutoApprove: complete!");
if (!found) { found = true;
core.setFailed("Unable to find release PR."); tries = 0;
});
}
if (!found) {
core.setFailed("Unable to find release PR after 3 tries.");
} }