type Github = {
token: string;
};
/**
* Set selected repositories for an organization variable
* Replaces all repositories for an organization variable that is available to selected repositories. Organization variables that are available to selected repositories have their `visibility` field set to `selected`. You must authenticate using an access token with the `admin:org` scope to use this endpoint. GitHub Apps must have the `organization_actions_variables:write` organization permission to use this endpoint.
*/
export async function main(
auth: Github,
org: string,
name: string,
body: { selected_repository_ids: number[]; [k: string]: unknown }
) {
const url = new URL(
`https://api.github.com/orgs/${org}/actions/variables/${name}/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 367 days ago
type Github = {
token: string;
};
/**
* Set selected repositories for an organization variable
* Replaces all repositories for an organization variable that is available to selected repositories. Organization variables that are available to selected repositories have their `visibility` field set to `selected`. You must authenticate using an access token with the `admin:org` scope to use this endpoint. GitHub Apps must have the `organization_actions_variables:write` organization permission to use this endpoint.
*/
export async function main(
auth: Github,
org: string,
name: string,
body: { selected_repository_ids: number[]; [k: string]: unknown }
) {
const url = new URL(
`https://api.github.com/orgs/${org}/actions/variables/${name}/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 927 days ago