//native
type Circleci = {
token: string
}
/**
* Cancel job by job ID
* Cancel job with a given job ID.
*/
export async function main(auth: Circleci, job_id: string) {
const url = new URL(`https://circleci.com/api/v2/jobs/${job_id}/cancel`)
const response = await fetch(url, {
method: 'POST',
headers: {
'Circle-Token': auth.token
},
body: undefined
})
if (!response.ok) {
const text = await response.text()
throw new Error(`${response.status} ${text}`)
}
return await response.json()
}
Submitted by hugo697 536 days ago