1 | |
2 | |
3 | * Deploy job |
4 | * You must provide a git commit id or an image tag depending on the source location of your code (git vs image repository). |
5 | */ |
6 | export async function main( |
7 | auth: RT.Qovery, |
8 | jobId: string, |
9 | body: Body, |
10 | forceEvent?: 'START' | 'STOP' | 'DELETE' | 'CRON' | undefined |
11 | ) { |
12 | const url = new URL(`https://api.qovery.com/job/${jobId}/deploy`) |
13 | for (const [k, v] of [['forceEvent', forceEvent]]) { |
14 | if (v !== undefined && v !== '') { |
15 | url.searchParams.append(k, v) |
16 | } |
17 | } |
18 | const response = await fetch(url, { |
19 | method: 'POST', |
20 | headers: { |
21 | 'Content-Type': 'application/json', |
22 | Authorization: 'Token ' + auth.apiKey |
23 | }, |
24 | body: JSON.stringify(body) |
25 | }) |
26 | if (!response.ok) { |
27 | const text = await response.text() |
28 | throw new Error(`${response.status} ${text}`) |
29 | } |
30 | return await response.json() |
31 | } |
32 |
|
33 | |
34 | |
35 | * This file was automatically generated by json-schema-to-typescript. |
36 | * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, |
37 | * and run json-schema-to-typescript to regenerate this file. |
38 | */ |
39 |
|
40 | export interface Body { |
41 | |
42 | * Image tag to deploy. |
43 | * Cannot be set if `git_commit_id` is defined |
44 | * |
45 | */ |
46 | image_tag?: string |
47 | |
48 | * Commit to deploy |
49 | * Cannot be set if `image_tag` is defined |
50 | * |
51 | */ |
52 | git_commit_id?: string |
53 | [k: string]: unknown |
54 | } |
55 |
|