forked from permaweb/ao
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.js
More file actions
27 lines (22 loc) · 699 Bytes
/
deploy.js
File metadata and controls
27 lines (22 loc) · 699 Bytes
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
import { z } from 'zod'
function env (key) {
const res = z.string().min(1).safeParse(process.env[key])
if (!res.success) {
console.error(`Error with ENV VAR: ${key}`)
throw res.error
}
return res.data
}
const deploy = async (deployHooksStr) => {
const deployHooks = z.preprocess(
(arg) => (typeof arg === 'string' ? arg.split(',').map(str => str.trim()) : arg),
z.array(z.string().url())
).parse(deployHooksStr)
const responses = await Promise.all(deployHooks.map(
(deployHook) => fetch(deployHook, { method: 'POST' })
.then((res) => res.json())
.catch((err) => err)
))
console.log('Deploy Responses:', responses)
}
deploy(env('DEPLOY_HOOKS'))