0

Re-run Failed Jobs

by
Published today

Re-run only the failed jobs (and their dependents) of a completed GitHub Actions workflow run. OAuth connections need the workflow scope.

Script github Verified

The script

Submitted by hugo989 Typescript (fetch-only)
Verified 1 hour ago
1
//native
2

3
/**
4
 * Re-run Failed Jobs
5
 * Re-run only the failed jobs (and their dependents) of a completed GitHub Actions workflow run. OAuth connections need the workflow scope.
6
 */
7
export async function main(
8
  auth: RT.Github,
9
  owner: string,
10
  repo: string,
11
  run_id: number,
12
) {
13
  const response = await fetch(
14
    `https://api.github.com/repos/${owner}/${repo}/actions/runs/${run_id}/rerun-failed-jobs`,
15
    {
16
      method: "POST",
17
      headers: {
18
        Authorization: `Bearer ${auth.token}`,
19
        Accept: "application/vnd.github+json",
20
        "X-GitHub-Api-Version": "2022-11-28",
21
      },
22
    },
23
  )
24

25
  if (!response.ok) {
26
    throw new Error(`${response.status} ${await response.text()}`)
27
  }
28

29
  return { success: true }
30
}
31