Skip to content

Commit

Permalink
chore: fix bot script to address github-script V5 changes (#4537)
Browse files Browse the repository at this point in the history
  • Loading branch information
equanz authored Dec 30, 2024
1 parent b660726 commit 14f2ae5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
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})

0 comments on commit 14f2ae5

Please sign in to comment.