Skip to content

Commit 2c13dce

Browse files
committed
feat: add checks rerun action
1 parent bee4677 commit 2c13dce

1 file changed

Lines changed: 42 additions & 0 deletions

File tree

pr/checks-rerun/action.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Rerun PR Checks
2+
description: Reruns failed or cancelled jobs of the latest completed run of a workflow for the current PR SHA
3+
4+
inputs:
5+
workflow-id:
6+
description: Workflow filename to rerun
7+
required: false
8+
default: pull-request.yml
9+
github-token:
10+
description: GitHub token with actions:write permission
11+
required: false
12+
default: ${{ github.token }}
13+
14+
runs:
15+
using: composite
16+
steps:
17+
- name: Rerun failed jobs
18+
uses: actions/github-script@v7
19+
with:
20+
github-token: ${{ inputs.github-token }}
21+
script: |
22+
const owner = context.repo.owner;
23+
const repo = context.repo.repo;
24+
const headSha = context.payload.pull_request.head.sha;
25+
26+
const runs = await github.rest.actions.listWorkflowRunsForRepo({
27+
owner,
28+
repo,
29+
workflow_id: '${{ inputs.workflow-id }}',
30+
event: 'pull_request',
31+
head_sha: headSha,
32+
status: 'completed',
33+
});
34+
35+
const run = runs.data.workflow_runs[0];
36+
if (run) {
37+
await github.rest.actions.reRunWorkflowFailedJobs({
38+
owner,
39+
repo,
40+
run_id: run.id,
41+
});
42+
}

0 commit comments

Comments
 (0)