0
Remove a selected repository from required workflow
One script reply has been approved by the moderators Verified

Removes a repository from a required workflow. To use this endpoint, the required workflow must be configured to run on selected repositories.

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

For more information, see "Required Workflows."

Created by hugo697 319 days ago Viewed 8987 times
0
Submitted by hugo697 Typescript (fetch-only)
Verified 319 days ago
1
type Github = {
2
  token: string;
3
};
4
/**
5
 * Remove a selected repository from required workflow
6
 * Removes a repository from a required workflow. To use this endpoint, the required workflow must be configured to run on selected repositories.
7

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

10
For more information, see "[Required Workflows](https://docs.github.com/actions/using-workflows/required-workflows)."
11
 */
12
export async function main(
13
  auth: Github,
14
  org: string,
15
  required_workflow_id: string,
16
  repository_id: string
17
) {
18
  const url = new URL(
19
    `https://api.github.com/orgs/${org}/actions/required_workflows/${required_workflow_id}/repositories/${repository_id}`
20
  );
21

22
  const response = await fetch(url, {
23
    method: "DELETE",
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.text();
34
}
35