-
Notifications
You must be signed in to change notification settings - Fork 1
96 lines (78 loc) · 2.77 KB
/
main.yml
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
name: app-engine
env:
GCLOUD_PROJECT_ID: hello-irkfap-com
on:
push:
branches:
- main
pull_request:
branches:
- main
types: [opened, synchronize, reopened]
jobs:
cancel-previous:
name: Cancel Previous Jobs
# Skip workflow entirely for [skip ci] commits
if: |
false == contains(github.event.commits[0].message, '[skip ci]') &&
false == contains(github.event.commits[0].message, '[no ci]')
runs-on: ubuntu-latest
steps:
- name: Cancel Previous Runs
uses: styfle/[email protected]
deploy-gae:
name: App Engine Deployment
# Skip workflow entirely for [skip ci] commits
if: |
false == contains(github.event.commits[0].message, '[skip ci]') &&
false == contains(github.event.commits[0].message, '[no ci]')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Cache pnpm modules
uses: actions/cache@v2
with:
path: ~/.pnpm-store
key: ${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-
- uses: pnpm/[email protected]
with:
version: 6.16.0
run_install: |
- args: [--frozen-lockfile]
- name: Import config.yaml
run: echo "${{ secrets.CONFIG_YAML }}" | base64 -d > config.yaml
- name: Import Service Account key
run: echo "${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}" | base64 -d > /tmp/auth.json
- name: GCloud Auth
run: |
gcloud --quiet auth \
activate-service-account "${{ secrets.GCP_SA_EMAIL }}" \
--key-file=/tmp/auth.json \
--project="${{ secrets.GCLOUD_PROJECT_ID }}"
- name: Generate static route handlers
run: yarn static
- name: Deploy
run: |
gcloud app deploy static.yaml --quiet --project="${GCLOUD_PROJECT_ID}" --no-promote --version="${GITHUB_ACTOR//[\[\]]/}-${GITHUB_SHA:0:7}"
production:
name: Update Production
environment: production
runs-on: ubuntu-latest
# Run only after successful deployment and Lighthouse audit
needs: [deploy-gae]
# Run only on push to master
if: ${{ success() && github.ref == 'refs/heads/main' }}
steps:
- name: Import Service Account key
run: echo "${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}" | base64 -d > /tmp/auth.json
- name: GCloud Auth
run: |
gcloud --quiet auth \
activate-service-account "${{ secrets.GCP_SA_EMAIL }}" \
--key-file=/tmp/auth.json \
--project="${GCLOUD_PROJECT_ID}"
- name: Promote deployed version to production
run: |
gcloud --quiet app versions migrate "${GITHUB_ACTOR//[\[\]]/}-${GITHUB_SHA:0:7}" --service=default