Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bot script to allow rerun failure checks command as expected #4537

Merged
merged 1 commit into from
Dec 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions .github/actions/bot/src/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
async function run(core, context, github) {

try {
const owner = process.env.PROVIDER;
const repo = process.env.REPOSITORY;
const owner = context.repo.owner;
const repo = context.repo.repo;
const reRunCmd = process.env.RERUN_CMD;
const comment = context.payload.comment.body;

if (comment !== reRunCmd) {
console.log("this is not a bot command");
core.info("this is not a bot command");
return;
}

Expand All @@ -35,13 +35,13 @@ async function run(core, context, github) {
sha: prRef,
}
}
} = await github.pulls.get({
} = await github.rest.pulls.get({
owner,
repo,
pull_number: context.issue.number,
});

const jobs = await github.checks.listForRef({
const jobs = await github.rest.checks.listForRef({
owner,
repo,
ref: prRef,
Expand All @@ -50,8 +50,8 @@ async function run(core, context, github) {

jobs.data.check_runs.forEach(job => {
if (job.conclusion === 'failure' || job.conclusion === 'cancelled') {
console.log("rerun job " + job.name);
github.checks.rerequestSuite({
core.info("rerun job " + job.name);
github.rest.checks.rerequestSuite({
owner,
repo,
check_suite_id: job.check_suite.id
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/bot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,10 @@ jobs:
- name: bot actions
uses: actions/github-script@v7
env:
PROVIDER: 'apache'
REPOSITORY: 'bookkeeper'
RERUN_CMD: 'rerun failure checks'
with:
github-token: ${{secrets.BKBOT_TOKEN}}
script: |
const path = require('path')
const scriptPath = path.resolve('.github/actions/bot/src/run.js')
require(scriptPath)({core}, {context}, {github})
require(scriptPath)({core}, {context}, {github})
Loading