-
Notifications
You must be signed in to change notification settings - Fork 0
170 lines (140 loc) · 5.6 KB
/
workflow.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
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
name: Deployment
on:
push:
branches:
- main
- qa
tags:
# Semver (these are glob-like patterns, not regexes; the "." has no special meaning)
- v[0-9].[0-9]+.[0-9]+
# Date-based
- v2[0-9]+.[0-9]+
pull_request:
permissions:
id-token: write
contents: read
concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
# Cancel in-progress builds on PRs, but not on staging deploys.
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set Environment
run: ./.github/scripts/set-environment.sh
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
- uses: actions/cache@v4
id: yarn-cache
with:
path: |
${{ steps.yarn-cache-dir-path.outputs.dir }}
node_modules
key: ${{ runner.os }}-yarn-2-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install dependencies
run: yarn
# This is currently failing because the server hasn't been started yet.
# Additionally, it's not enough to just output the generated types file.
# We need to create a script that checks that our types file is up to date.
#- name: generate schemas
# run: yarn generate-types
- name: Check that code is formatted
run: yarn prettier --check .
- name: Generate strings
run: yarn generate-strings
# Disable the linter since it will not pass in its current state
# - name: Run linter
# run: yarn lint
- name: Do typescript check
run: yarn ts
- name: Run unit tests
run: yarn test --ci
- name: Download and start backend
if: github.ref != 'refs/heads/main' && !startsWith(github.ref, 'refs/tags/')
run: yarn server:reset
env:
SPRING_SECURITY_OAUTH2_CLIENT_PROVIDER_KEYCLOAK_ISSUERURI: https://auth.staging.terraware.io/realms/terraware
SPRING_SECURITY_OAUTH2_CLIENT_REGISTRATION_KEYCLOAK_CLIENTSECRET: dummy
SPRING_SECURITY_OAUTH2_RESOURCESERVER_JWT_ISSUERURI: https://auth.staging.terraware.io/realms/terraware
TERRAWARE_MAPBOX_API_TOKEN: ${{ secrets.REACT_APP_MAPBOX_TOKEN }}
- name: Install Playwright Browsers
run: yarn playwright install --with-deps
- name: Run end-to-end playwright tests
# Skip tests on main and releases because of Cypress hanging bug
if: github.ref != 'refs/heads/main' && !startsWith(github.ref, 'refs/tags/')
run: yarn test:e2e
env:
REACT_APP_TERRAWARE_API: 'http://localhost:8080'
REACT_APP_SNACKBAR_TIMEOUT: 1000
REACT_APP_TERRAWARE_FE_BUILD_VERSION: ${{ env.APP_VERSION }}
- name: save screenshots of e2e test failures
if: failure()
uses: actions/upload-artifact@v3
with:
name: playwright-report
path: playwright-report/
retention-days: 30
- name: build
run: yarn build
env:
REACT_APP_TERRAWARE_API: ''
REACT_APP_TERRAWARE_FE_BUILD_VERSION: ${{ env.APP_VERSION }}
REACT_APP_MIXPANEL_TOKEN: ${{ secrets[env.MIXPANEL_SECRET] }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Docker login
if: env.IS_CD == 'true'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Docker build/push
uses: docker/build-push-action@v5
with:
context: .
cache-from: type=gha
cache-to: type=gha, mode=max
tags: ${{ env.DOCKER_TAGS }}
platforms: linux/amd64,linux/arm64
push: ${{ env.IS_CD == 'true' }}
- name: Configure AWS Credentials
if: env.IS_CD == 'true'
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: ${{ secrets[env.AWS_REGION_SECRET_NAME] }}
role-to-assume: ${{ secrets[env.AWS_ROLE_SECRET_NAME] }}
- name: Connect to Tailscale
uses: tailscale/github-action@v2
with:
oauth-client-id: ${{ secrets.TAILSCALE_OAUTH_CLIENT_ID }}
oauth-secret: ${{ secrets.TAILSCALE_OAUTH_CLIENT_SECRET }}
tags: tag:github
- name: Deploy
if: env.IS_CD == 'true'
env:
SSH_KEY: ${{ secrets[env.SSH_KEY_SECRET_NAME] }}
SSH_USER: ${{ secrets[env.SSH_USER_SECRET_NAME] }}
run: ./.github/scripts/deploy.sh
- name: Jira Login
if: env.TIER == 'PROD'
uses: atlassian/gajira-login@master
env:
JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }}
JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }}
JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }}
- name: Create Jira Transition List
if: env.TIER == 'PROD'
run: curl https://terraware.github.io/terraware-web/unreleased.log | grep -E 'SW-[0-9]+' -o | sort -u > ./docs/jiralist.txt
- name: Transition Jiras
if: env.TIER == 'PROD'
uses: terraware/gajira-transition-multiple@master
with:
issueList: ./docs/jiralist.txt
transition: 'Released to Production from Done'