-
Notifications
You must be signed in to change notification settings - Fork 42
182 lines (162 loc) · 6.25 KB
/
feature-branch_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
182
name: Feature branch deployment
on:
push:
branches-ignore: [ master, staging, gtif-demo, gtif_staging, polar ]
concurrency:
group: ci-tests-${{ github.ref }}-1
cancel-in-progress: true
jobs:
deploy:
if: github.event_name != 'pull_request' # Only run deploy for pushes not for pull requests
runs-on: ubuntu-22.04
steps:
# Checkout code
- uses: actions/checkout@v3
# Install node
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: '16'
registry-url: 'https://registry.npmjs.org'
cache: 'npm'
cache-dependency-path: app/package-lock.json
# Build
- name: Build
run: |
cd app/
sed -e "s,// publicPath: '/',publicPath: '/${GITHUB_REF##*/}'," -i vue.config.js
npm ci --ignore-scripts
npm run build -- --mode development
# Inject SH Config file
- name: replace instance ID
uses: datamonsters/replace-action@v2
with:
files: 'app/dist/shConfig.js'
replacements: '$SH_INSTANCE_ID=${{ secrets.SH_INSTANCE_ID }},$SH_INSTANCE_ID_POLAR=${{ secrets.SH_INSTANCE_ID_POLAR }},$GEODB_INSTANCE_ID=${{ secrets.GEODB_INSTANCE_ID }},$LISTMONK_API_KEY=${{ secrets.LISTMONK_API_KEY }},$STAT_API_CLIENT_SECRET=${{ secrets.STAT_API_CLIENT_SECRET }},$STAT_API_CLIENT_ID=${{ secrets.STAT_API_CLIENT_ID }},$SH_INSTANCE_ID_GTIF=${{ secrets.SH_INSTANCE_ID_GTIF }},$OPENCAGE_RACE=${{ secrets.OPENCAGE_EOX }},$OPENCAGE_GTIF=${{ secrets.OPENCAGE_EOX }},$OPENCAGE_TRILATERAL=${{ secrets.OPENCAGE_EOX }},$SH_INSTANCE_ID_IDEAS=${{ secrets.SH_INSTANCE_ID_IDEAS }}'
# Upload build client to S3
- name: sync client s3
uses: jakejarvis/s3-sync-action@v0.5.1
with:
args: --delete --follow-symlinks --exclude 'data/*' --exclude 'eodash-data/*'
env:
SOURCE_DIR: 'app/dist'
DEST_DIR: 'feature-branches/${GITHUB_REF##*/}'
AWS_REGION: 'eu-central-1'
AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
# Upload data to S3
- name: sync data s3
uses: jakejarvis/s3-sync-action@v0.5.1
with:
args: --delete --follow-symlinks --size-only
env:
SOURCE_DIR: 'app/dist/data'
DEST_DIR: 'feature-branches/${GITHUB_REF##*/}/data'
AWS_REGION: 'eu-central-1'
AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
# Upload eodashdata to S3
- name: sync eodashdata s3
uses: jakejarvis/s3-sync-action@v0.5.1
with:
args: --delete --follow-symlinks --size-only
env:
SOURCE_DIR: 'app/dist/eodash-data'
DEST_DIR: 'feature-branches/${GITHUB_REF##*/}/eodash-data'
AWS_REGION: 'eu-central-1'
AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
# Invalidate Cloudfront
- name: invalidate
uses: chetan/invalidate-cloudfront-action@v1.2
env:
DISTRIBUTION: ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID_FEATUREBRANCHES }}
PATHS: '/*' # TODO: Only invalidate the current branch. "PATHS: '/${GITHUB_REF##*/}/*'" didn't work.
AWS_REGION: 'eu-central-1'
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
# Send notification
- name: action-slack
uses: 8398a7/action-slack@v3.15.1
with:
status: ${{ job.status }}
author_name: eodash_deploy
fields: repo,message,commit,author,action,eventName,ref,workflow
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # required
if: always()
cypress-run-gtif:
needs: deploy
name: Cypress run feature branch GTIF
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3
# Tests for GTIF
- name: Cypress run
uses: cypress-io/github-action@v4
with:
working-directory: app
spec: tests/e2e/specs/indicators_gtif.js
config: 'baseUrl=https://${{ secrets.TEST_INSTANCE_UN }}:${{ secrets.TEST_INSTANCE_PW }}@gtif-testing.eox.at/${{ github.ref_name }}/'
- uses: actions/upload-artifact@v3
if: failure()
with:
name: cypress-screenshots
path: app/tests/e2e/screenshots
- uses: actions/upload-artifact@v3
if: always()
with:
name: cypress-videos
path: app/tests/e2e/videos
cypress-run-race:
needs: deploy
name: Cypress run feature branch RACE
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3
# Tests for RACE
- name: Cypress run
uses: cypress-io/github-action@v4
with:
working-directory: app
spec: tests/e2e/specs/indicators_race.js
config: 'baseUrl=https://${{ secrets.TEST_INSTANCE_UN }}:${{ secrets.TEST_INSTANCE_PW }}@eodash-testing.eox.at/${{ github.ref_name }}/'
- uses: actions/upload-artifact@v3
if: failure()
with:
name: cypress-screenshots
path: app/tests/e2e/screenshots
- uses: actions/upload-artifact@v3
if: always()
with:
name: cypress-videos
path: app/tests/e2e/videos
cypress-run-trilateral:
needs: deploy
name: Cypress run feature branch Trilateral
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3
# Tests for trilateral
- name: Cypress run
uses: cypress-io/github-action@v4
with:
working-directory: app
spec: tests/e2e/specs/indicators_trilateral.js
config: 'baseUrl=https://${{ secrets.TEST_INSTANCE_UN }}:${{ secrets.TEST_INSTANCE_PW }}@eodash-trilateral-testing.eox.at/${{ github.ref_name }}/'
- uses: actions/upload-artifact@v3
if: failure()
with:
name: cypress-screenshots
path: app/tests/e2e/screenshots
- uses: actions/upload-artifact@v3
if: always()
with:
name: cypress-videos
path: app/tests/e2e/videos