-
Notifications
You must be signed in to change notification settings - Fork 46
/
deploy.ts
34 lines (32 loc) · 900 Bytes
/
deploy.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { baseUrl } from '../baseUrl'
import { getCreds } from '../../creds'
import { request } from '../request'
export type ResponseBody = {
id: string
status: 'CREATED' | 'DEPLOYING' | 'ERROR' | 'OK'
name: string
artifactUrl: string
version: number
}
export async function deploy(
deploymentName: string,
artifactUrl: string
): Promise<string | undefined> {
const apiUrl = `${baseUrl}/client/deployment`
const response = await request(apiUrl, {
method: 'post',
body: JSON.stringify({
name: deploymentName,
artifactUrl,
}),
headers: {
// eslint-disable-next-line @typescript-eslint/naming-convention
'Content-Type': 'application/json',
authorization: `token ${getCreds()}`,
},
})
const responseBody = await response.json()
if (response.status === 200) {
return `Created deployment with name ${responseBody.name}`
}
}