-
Notifications
You must be signed in to change notification settings - Fork 10
64 lines (54 loc) · 1.97 KB
/
deploy-dev.yml
File metadata and controls
64 lines (54 loc) · 1.97 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# This workflow deploys any branch or tag to the staging environment.
name: Staging Deployment
on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
inputs:
tag:
description: The branch, tag, or commit hash to deploy
required: false
default: master
type: string
jobs:
deploy:
# Allow the job to fetch a GitHub ID token
permissions:
id-token: write
contents: read
runs-on: ubuntu-latest
env:
TAG: ${{ github.event.inputs.tag }}
steps:
- uses: actions/checkout@v6
- name: Authenticate with Google Cloud
id: auth
uses: google-github-actions/auth@v3
with:
workload_identity_provider: ${{ secrets.WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ secrets.GCP_SERVICE_ACCOUNT }}
create_credentials_file: true
cleanup_credentials: true
export_environment_variables: true
- name: Setup gcloud
uses: google-github-actions/setup-gcloud@v3
with:
project_id: ${{ secrets.GCP_PROJECT_ID }}
skip_install: true
- name: Run deploy script
run: |
instance_prefix='openreview-dev-'
instances=$(gcloud compute instances list | grep "$instance_prefix" | grep RUNNING | tr -s ' ' | cut -d' ' -f1,2)
instances_arr=(${instances// / })
instance_names=()
zones=()
for i in ${!instances_arr[@]}; do
if echo "${instances_arr[$i]}" | grep -q "$instance_prefix"; then
instance_names+=(${instances_arr[$i]})
else
zones+=(${instances_arr[$i]})
fi
done
for i in ${!instance_names[@]}; do
echo Deploying to ${instance_names[$i]}
gcloud compute ssh --zone ${zones[$i]} --tunnel-through-iap openreview@${instance_names[$i]} --command "bash bin/build-web.sh ${TAG} && bash bin/deploy-web.sh ${TAG}"
done