type Github = {
token: string;
};
/**
* Create or update an environment secret
* Creates or updates an environment secret with an encrypted value.
*/
export async function main(
auth: Github,
repository_id: string,
environment_name: string,
secret_name: string,
body: { encrypted_value: string; key_id: string; [k: string]: unknown }
) {
const url = new URL(
`https://api.github.com/repositories/${repository_id}/environments/${environment_name}/secrets/${secret_name}`
);
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.json();
}
Submitted by hugo697 407 days ago