//native
type Circleci = {
token: string
}
/**
* Create a schedule
* Not yet available to projects that use GitLab or GitHub App. Creates a schedule and returns the created schedule.
*/
export async function main(
auth: Circleci,
project_slug: string,
body: {
name: string
timetable:
| {
'per-hour': number
'hours-of-day': number[]
'days-of-week': 'TUE' | 'SAT' | 'SUN' | 'MON' | 'THU' | 'WED' | 'FRI'[]
'days-of-month'?: number[]
months?:
| 'MAR'
| 'NOV'
| 'DEC'
| 'JUN'
| 'MAY'
| 'OCT'
| 'FEB'
| 'APR'
| 'SEP'
| 'AUG'
| 'JAN'
| 'JUL'[]
}
| {
'per-hour': number
'hours-of-day': number[]
'days-of-month': number[]
'days-of-week'?: 'TUE' | 'SAT' | 'SUN' | 'MON' | 'THU' | 'WED' | 'FRI'[]
months?:
| 'MAR'
| 'NOV'
| 'DEC'
| 'JUN'
| 'MAY'
| 'OCT'
| 'FEB'
| 'APR'
| 'SEP'
| 'AUG'
| 'JAN'
| 'JUL'[]
}
'attribution-actor': 'current' | 'system'
parameters: {}
description?: string
}
) {
const url = new URL(`https://circleci.com/api/v2/project/${project_slug}/schedule`)
const response = await fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Circle-Token': 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 536 days ago