-
Notifications
You must be signed in to change notification settings - Fork 1
182 lines (174 loc) · 5.88 KB
/
quasar_deploy.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
name: Release branch CICD
on:
push:
branches: [ master ]
jobs:
pre_check:
name: Test and semver
runs-on: ubuntu-latest
outputs:
new_release_published: ${{ steps.semantic.outputs.new_release_published }}
new_release_version: ${{ steps.semantic.outputs.new_release_version }}
defaults:
run:
working-directory: ./client
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Set up Node (16)
uses: actions/setup-node@v1
with:
node-version: 16.x
cache: 'npm'
cache-dependency-path: client/package-lock.json
- name: NPM ci
run: npm ci
- name: Test
run: npx quasar test --unit jest
- name: Semantic Release
id: semantic
uses: cycjimmy/semantic-release-action@v3
with:
semantic_version: 19.0.5
dry_run: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Version check
if: ${{ steps.semantic.outputs.new_release_published == 'true' }}
run: echo "Preparing version ${{ steps.semantic.outputs.new_release_version }}"
build:
name: Build front-end
needs: [ pre_check ]
if: needs.pre_check.outputs.new_release_published == 'true'
outputs:
new_release_published: ${{ needs.pre_check.outputs.new_release_published }}
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./client
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Set up Node (16)
uses: actions/setup-node@v1
with:
node-version: 16.x
cache: 'npm'
cache-dependency-path: client/package-lock.json
- name: NPM ci
run: npm ci
- name: Semantic Release
id: semantic
uses: cycjimmy/semantic-release-action@v3
with:
semantic_version: 19.0.5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Set package.json version
run: npm version ${{ steps.semantic.outputs.new_release_version }} --no-git-tag-version
- name: Build
run: npx quasar build --publish sentry
- name: Determine version
run: echo "SOURCE_VERSION=$(jq -r .version package.json)" >> $GITHUB_ENV
- name: Determine version
run: echo "Deploying version $SOURCE_VERSION"
- name: Create Sentry release
uses: getsentry/action-release@v1
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }}
# SENTRY_URL: https://sentry.io/
with:
environment: production
sourcemaps: ./client/dist/spa
finalize: false
ignore_missing: true
ignore_empty: true
version: gainstrack@${{ env.SOURCE_VERSION }}
- name: Remove Source Maps
run: |
# Remove all source maps
find ./dist/spa -regextype posix-extended -regex '.*.(js|css).map$' -type f -delete
# Remove source map references in files
sed -i 's/^\/\/# sourceMappingURL=.*$//' $(find ./dist/spa -regextype posix-extended -regex '.*.(js|css)$' -type f)
- name: Upload Build Artifacts
uses: actions/upload-artifact@v2
with:
name: build-artifacts
path: "./client/dist/spa"
deploy_client:
name: Deploy
runs-on: ubuntu-latest
needs: [ build ]
if: needs.build.outputs.new_release_published == 'true'
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Download Build Artifacts
uses: actions/download-artifact@v2
with:
name: build-artifacts
path: "./client/dist/spa"
- name: Deploy poc
uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: '${{ secrets.GITHUB_TOKEN }}'
firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_GAINSTRACK }}'
projectId: gainstrack
target: poc
channelId: live
entryPoint: ./client
- name: Deploy prod
uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: '${{ secrets.GITHUB_TOKEN }}'
firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_GAINSTRACK }}'
projectId: gainstrack
target: prod
channelId: live
entryPoint: ./client
release_backend:
name: Build and test backend
runs-on: ubuntu-latest
needs: [ pre_check ]
if: needs.pre_check.outputs.new_release_published == 'true'
env:
IMAGE_NAME: gcr.io/${{ secrets.GCP_PROJECT_ID }}/${{ secrets.GCP_APP_NAME }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
- id: 'auth'
uses: 'google-github-actions/auth@v1'
with:
credentials_json: '${{ secrets.GCP_CREDENTIALS }}'
- name: 'Set up Cloud SDK'
uses: 'google-github-actions/setup-gcloud@v1'
- name: Configure Docker
run: gcloud auth configure-docker --quiet
- name: Build Docker image
run: docker build . --file fast.Dockerfile -t $IMAGE_NAME
- name: Push Docker image
run: docker push $IMAGE_NAME
deploy_backend:
name: Deploy backend
runs-on: ubuntu-latest
needs: [ release_backend ]
strategy:
matrix:
server: [ "quotes", "appserver" ]
steps:
- id: 'auth'
uses: 'google-github-actions/auth@v1'
with:
credentials_json: '${{ secrets.GCP_CREDENTIALS }}'
- name: 'Set up Cloud SDK'
uses: 'google-github-actions/setup-gcloud@v1'
- name: Release ${{ matrix.server }} server
run: |-
gcloud run deploy ${{ matrix.server }} \
--region asia-northeast1 \
--image gcr.io/gainstrack/gainstrack \
--platform managed \
--allow-unauthenticated \
--project gainstrack