Remove all custom labels from a self-hosted runner for an organization

Remove all custom labels from a self-hosted runner configured in an organization. Returns the remaining read-only labels from the runner. You must authenticate using an access token with the `admin:org` scope to use this endpoint.

Script github Verified

by hugo697 ยท 10/25/2023

The script

Submitted by hugo697 Typescript (fetch-only)
Verified 366 days ago
1
type Github = {
2
  token: string;
3
};
4
/**
5
 * Remove all custom labels from a self-hosted runner for an organization
6
 * Remove all custom labels from a self-hosted runner configured in an
7
organization. Returns the remaining read-only labels from the runner.
8

9
You must authenticate using an access token with the `admin:org` scope to use this endpoint.
10
 */
11
export async function main(auth: Github, org: string, runner_id: string) {
12
  const url = new URL(
13
    `https://api.github.com/orgs/${org}/actions/runners/${runner_id}/labels`
14
  );
15

16
  const response = await fetch(url, {
17
    method: "DELETE",
18
    headers: {
19
      Authorization: "Bearer " + auth.token,
20
    },
21
    body: undefined,
22
  });
23
  if (!response.ok) {
24
    const text = await response.text();
25
    throw new Error(`${response.status} ${text}`);
26
  }
27
  return await response.json();
28
}
29