type Github = {
token: string;
};
/**
* Create an organization variable
* Creates an organization variable that you can reference in a GitHub Actions workflow.
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,
body: {
name: string;
selected_repository_ids?: number[];
value: string;
visibility: "all" | "private" | "selected";
[k: string]: unknown;
}
) {
const url = new URL(`https://api.github.com/orgs/${org}/actions/variables`);
const response = await fetch(url, {
method: "POST",
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.json();
}
Submitted by hugo697 367 days ago
type Github = {
token: string;
};
/**
* Create an organization variable
* Creates an organization variable that you can reference in a GitHub Actions workflow.
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,
body: {
name: string;
selected_repository_ids?: number[];
value: string;
visibility: "all" | "private" | "selected";
[k: string]: unknown;
}
) {
const url = new URL(`https://api.github.com/orgs/${org}/actions/variables`);
const response = await fetch(url, {
method: "POST",
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.json();
}
Submitted by hugo697 927 days ago