0
Create a remove token for a repository
One script reply has been approved by the moderators Verified

Returns a token that you can pass to remove a self-hosted runner from a repository. The token expires after one hour. You must authenticate using an access token with the repo scope to use this endpoint.

Example using remove token

To remove your self-hosted runner from a repository, replace TOKEN with the remove token provided by this endpoint.

./config.sh remove --token TOKEN
Created by hugo697 176 days ago Viewed 3958 times
0
Submitted by hugo697 Typescript (fetch-only)
Verified 176 days ago
1
type Github = {
2
  token: string;
3
};
4
/**
5
 * Create a remove token for a repository
6
 * Returns a token that you can pass to remove a self-hosted runner from a repository. The token expires after one hour.
7
You must authenticate using an access token with the `repo` scope to use this endpoint.
8

9
#### Example using remove token
10
 
11
To remove your self-hosted runner from a repository, replace TOKEN with the remove token provided by this endpoint.
12

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

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