Skip to content

Commit

Permalink
Add "skip_check" action type to bcr-pr-reviewer (#2102)
Browse files Browse the repository at this point in the history
Basically cut-pasted from release-helper.
  • Loading branch information
Wyverald authored Nov 5, 2024
1 parent a423d66 commit 854de5d
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 8 deletions.
2 changes: 1 addition & 1 deletion actions/bcr-pr-reviewer/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ inputs:
default: ${{ github.token }}

action-type:
description: 'The type of action this reviewer should perform, valid values are: notify_maintainers, review_prs, dismiss_approvals'
description: 'The type of action this reviewer should perform, valid values are: notify_maintainers, review_prs, dismiss_approvals, skip_check'
required: true

runs:
Expand Down
37 changes: 37 additions & 0 deletions actions/bcr-pr-reviewer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,41 @@ async function runDismissApproval(octokit) {
}
}

const SKIP_CHECK_TRIGGER = "@bazel-io skip_check ";

async function runSkipCheck(octokit) {
const payload = context.payload;
if (!payload.comment.body.startsWith(SKIP_CHECK_TRIGGER)) {
return;
}
const check = payload.comment.body.slice(SKIP_CHECK_TRIGGER.length);
const owner = payload.repository.owner.login;
const repo = payload.repository.name;
if (check == "unstable_url") {
await octokit.rest.issues.addLabels({
owner,
repo,
issue_number: payload.issue.number,
labels: ["skip-url-stability-check"],
});
await octokit.rest.reactions.createForIssueComment({
owner,
repo,
comment_id: payload.comment.id,
content: '+1',
});
} else {
await octokit.rest.reactions.createForIssueComment({
owner,
repo,
comment_id: payload.comment.id,
content: 'confused',
});
console.error(`unknown check: ${check}`);
setFailed(`unknown check: ${check}`);
}
}

async function run() {
const action_type = getInput("action-type");
const token = getInput("token");
Expand All @@ -453,6 +488,8 @@ async function run() {
await runPrReviewer(octokit);
} else if (action_type === "dismiss_approvals") {
await runDismissApproval(octokit);
} else if (action_type === "skip_check") {
await runSkipCheck(octokit);
} else {
console.log(`Unknown action type: ${action_type}`);
}
Expand Down
7 changes: 0 additions & 7 deletions actions/release-helper/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,6 @@ async function run() {
issue_number: payload.issue.number,
labels: [FLAGGED_LABEL],
});
} else if (command === "unstable_ack" || command.startsWith("unstable_ack ")) {
await octokit.rest.issues.addLabels({
owner,
repo,
issue_number: payload.issue.number,
labels: ["skip-url-stability-check"],
});
} else {
await octokit.rest.reactions.createForIssueComment({
owner,
Expand Down

0 comments on commit 854de5d

Please sign in to comment.