type Github = {
token: string;
};
/**
* Sets repositories for a required workflow
* Sets the repositories for a required workflow that is required for selected repositories.
You must authenticate using an access token with the `admin:org` scope to use this endpoint.
For more information, see "[Required Workflows](https://docs.github.com/actions/using-workflows/required-workflows)."
*/
export async function main(
auth: Github,
org: string,
required_workflow_id: string,
body: { selected_repository_ids: number[]; [k: string]: unknown }
) {
const url = new URL(
`https://api.github.com/orgs/${org}/actions/required_workflows/${required_workflow_id}/repositories`
);
const response = await fetch(url, {
method: "PUT",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer " + auth.token,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.text();
}
Submitted by hugo697 304 days ago
type Github = {
token: string;
};
/**
* Sets repositories for a required workflow
* Sets the repositories for a required workflow that is required for selected repositories.
You must authenticate using an access token with the `admin:org` scope to use this endpoint.
For more information, see "[Required Workflows](https://docs.github.com/actions/using-workflows/required-workflows)."
*/
export async function main(
auth: Github,
org: string,
required_workflow_id: string,
body: { selected_repository_ids: number[]; [k: string]: unknown }
) {
const url = new URL(
`https://api.github.com/orgs/${org}/actions/required_workflows/${required_workflow_id}/repositories`
);
const response = await fetch(url, {
method: "PUT",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer " + auth.token,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.text();
}
Submitted by hugo697 864 days ago