Create a remove token for an organization

Returns a token that you can pass to the `config` script to remove a self-hosted runner from an organization. The token expires after one hour. You must authenticate using an access token with the `admin:org` scope to use this endpoint. #### Example using remove token To remove your self-hosted runner from an organization, replace `TOKEN` with the remove token provided by this endpoint. ``` ./config.sh remove --token TOKEN ```

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
 * Create a remove token for an organization
6
 * Returns a token that you can pass to the `config` script to remove a self-hosted runner from an organization. The token expires after one hour.
7

8
You must authenticate using an access token with the `admin:org` scope to use this endpoint.
9

10
#### Example using remove token
11

12
To remove your self-hosted runner from an organization, replace `TOKEN` with the remove token provided by this
13
endpoint.
14

15
```
16
./config.sh remove --token TOKEN
17
```
18
 */
19
export async function main(auth: Github, org: string) {
20
  const url = new URL(
21
    `https://api.github.com/orgs/${org}/actions/runners/remove-token`
22
  );
23

24
  const response = await fetch(url, {
25
    method: "POST",
26
    headers: {
27
      Authorization: "Bearer " + auth.token,
28
    },
29
    body: undefined,
30
  });
31
  if (!response.ok) {
32
    const text = await response.text();
33
    throw new Error(`${response.status} ${text}`);
34
  }
35
  return await response.json();
36
}
37