-
Notifications
You must be signed in to change notification settings - Fork 3
61 lines (49 loc) · 1.58 KB
/
build-and-deploy.yml
File metadata and controls
61 lines (49 loc) · 1.58 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
name: Build and Deploy to GCP
on:
push:
branches: [ deploy-prod, deploy-staging, deploy-dev ]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Cache node modules
uses: actions/cache@v4
with:
path: node_modules
key: ${{ runner.OS }}-build-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.OS }}-build-
${{ runner.OS }}-
- name: Use Node.js
uses: actions/setup-node@v2
with:
node-version: 20
- name: Install dependencies
run: yarn install
- name: Build
run: yarn build
# Somewhat weirdly you do the auth before the setup for the google CLI
- name: Authenticate the cloud sdk
uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.GCP_SA_KEY }}
export_environment_variables: true
- name: Setup cloud sdk
uses: google-github-actions/setup-gcloud@v2
with:
project_id: ${{ secrets.GCP_PROJECT_ID }}
- name: Deploy to GCS
run: |
BUCKET_NAME="$(echo ${BRANCH_NAME} | cut -d'-' -f 2)"
if [[ "$BUCKET_NAME" == "prod" ]]; then
BUCKET_NAME="www"
fi
BUCKET_NAME="${BUCKET_NAME}.baaahs.org"
gsutil -m rsync -r -d ./build gs://${BUCKET_NAME}
gcloud compute url-maps invalidate-cdn-cache lb-map --path=/* --async
env:
BRANCH_NAME: ${{ github.ref }}
shell: bash