Add `\rerun <ID>` command for failed jobs in workflows (#3095)

Signed-off-by: Bernd Verst <github@bernd.dev>
This commit is contained in:
Bernd Verst 2023-08-21 17:53:35 -07:00 committed by GitHub
parent 9be6d157a4
commit b65f1ea243
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 19 additions and 0 deletions

View File

@ -94,6 +94,10 @@ async function handleIssueCommentCreate({ github, context }) {
case '/ok-to-test':
await cmdOkToTest(github, issue, isFromPulls)
break
case command.match(/^\/rerun \d+/)?.input:
const workflowrunid = command.match(/\d+/)[0];
await rerunWorkflow(github, issue, workflowrunid)
break
default:
console.log(
`[handleIssueCommentCreate] command ${command} not found, exiting.`
@ -234,3 +238,18 @@ async function cmdOkToTest(github, issue, isFromPulls) {
)
}
}
/**
* Rerun all failed jobs of a given workflow run ID.
* @param {*} github GitHub object reference
* @param {*} issue GitHub issue object
* @param {int} workflowrunid the workflow run ID for which to rerun all failed jobs
*/
async function rerunWorkflow(github, issue, workflowrunid) {
// Rerun all failed jobs of the specified workflow run
const pull = await github.rest.actions.reRunWorkflowFailedJobs({
owner: issue.owner,
repo: issue.repo,
run_id: workflowrunid,
});
}