1 | |
2 | type Netlify = { |
3 | token: string; |
4 | }; |
5 | |
6 | * Update site deploy |
7 | * |
8 | */ |
9 | export async function main( |
10 | auth: Netlify, |
11 | site_id: string, |
12 | deploy_id: string, |
13 | body: { |
14 | files?: {}; |
15 | draft?: false | true; |
16 | async?: false | true; |
17 | functions?: {}; |
18 | function_schedules?: { name?: string; cron?: string }[]; |
19 | functions_config?: {}; |
20 | branch?: string; |
21 | framework?: string; |
22 | framework_version?: string; |
23 | }, |
24 | ) { |
25 | const url = new URL( |
26 | `https://api.netlify.com/api/v1/sites/${site_id}/deploys/${deploy_id}`, |
27 | ); |
28 |
|
29 | const response = await fetch(url, { |
30 | method: "PUT", |
31 | headers: { |
32 | "Content-Type": "application/json", |
33 | Authorization: "Bearer " + auth.token, |
34 | }, |
35 | body: JSON.stringify(body), |
36 | }); |
37 | if (!response.ok) { |
38 | const text = await response.text(); |
39 | throw new Error(`${response.status} ${text}`); |
40 | } |
41 | return await response.json(); |
42 | } |
43 |
|