-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy.sh
executable file
·46 lines (41 loc) · 997 Bytes
/
deploy.sh
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
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/bash
set -eu
deploy_pub () {
(cd pub && go mod tidy)
gcloud functions deploy slack-gemini-pub \
--gen2 \
--runtime=go122 \
--region=asia-northeast1 \
--source=./pub \
--entry-point=Publish \
--trigger-http \
--allow-unauthenticated \
--env-vars-file=./.env.yaml \
--service-account="$1"
}
deploy_sub () {
(cd sub && go mod tidy)
gcloud functions deploy slack-gemini-sub \
--gen2 \
--runtime=go122 \
--region=asia-northeast1 \
--source=./sub \
--entry-point=Subscribe \
--trigger-topic=slack-gemini \
--env-vars-file=./.env.yaml \
--service-account="$1"
}
main () {
cd "$(realpath "$(dirname "$0")")"
local service_account="$(yq -r '.SERVICE_ACCOUNT' < .env.yaml)"
[[ $# -lt 1 || "$1" = 'pub' ]] && {
echo -e 'Start deploying slack-gemini-pub function...\n'
deploy_pub "$service_account"
echo
}
[[ $# -lt 1 || "$1" = 'sub' ]] && {
echo -e 'Start deploying slack-gemini-sub function...\n'
deploy_sub "$service_account"
}
}
main "$@"