type Github = {
token: string;
};
/**
* Create a workflow dispatch event
* You can use this endpoint to manually trigger a GitHub Actions workflow run.
*/
export async function main(
auth: Github,
owner: string,
repo: string,
workflow_id: string,
body: { inputs?: { [k: string]: string }; ref: string; [k: string]: unknown }
) {
const url = new URL(
`https://api.github.com/repos/${owner}/${repo}/actions/workflows/${workflow_id}/dispatches`
);
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.text();
}
Submitted by hugo697 58 days ago
type Github = {
token: string;
};
/**
* Create a workflow dispatch event
* You can use this endpoint to manually trigger a GitHub Actions workflow run.
*/
export async function main(
auth: Github,
owner: string,
repo: string,
workflow_id: string,
body: { inputs?: { [k: string]: string }; ref: string; [k: string]: unknown }
) {
const url = new URL(
`https://api.github.com/repos/${owner}/${repo}/actions/workflows/${workflow_id}/dispatches`
);
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.text();
}
Submitted by hugo697 618 days ago