-
Notifications
You must be signed in to change notification settings - Fork 26
129 lines (103 loc) · 3.25 KB
/
actions.yaml
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
name: Fleet Routing App CI
on:
push:
jobs:
# detect changes
changes:
runs-on: ubuntu-latest
outputs:
backend: ${{ steps.filter.outputs.backend }}
frontend: ${{ steps.filter.outputs.frontend }}
steps:
- uses: actions/checkout@v3
- uses: dorny/paths-filter@v2
id: filter
with:
filters: |
backend:
- 'application/backend/**'
frontend:
- 'application/frontend/**'
# backend checks
check-backend:
needs: changes
if: ${{ needs.changes.outputs.backend == 'true' }}
runs-on: ubuntu-latest
defaults:
run:
working-directory: application/backend
steps:
- uses: actions/checkout@v3
- name: Use Node.js v16 LTS
uses: actions/setup-node@v3
with:
node-version: '16'
cache: 'npm'
cache-dependency-path: application/backend/package-lock.json
- run: npm ci
- run: npm run lint
- run: npm test
# frontend checks
check-frontend:
needs: changes
if: ${{ needs.changes.outputs.frontend == 'true' }}
runs-on: ubuntu-latest
defaults:
run:
working-directory: application/frontend
steps:
- uses: actions/checkout@v3
- name: Use Node.js v16 LTS
uses: actions/setup-node@v3
with:
node-version: '16'
cache: 'npm'
cache-dependency-path: application/frontend/package-lock.json
- run: npm ci
- run: npm run lint
- run: npm run style-check
- run: Xvfb :99 &
- run: npm run test -- --watch=false --progress=false --browsers=ChromeHeadlessCI --code-coverage
env:
DISPLAY: ':99'
# build container image
build-container:
needs:
- check-backend
- check-frontend
if: |
always() &&
(needs.check-backend.result == 'success' || needs.check-backend.result == 'skipped') &&
(needs.check-frontend.result == 'success' || needs.check-frontend.result == 'skipped')
runs-on: ubuntu-latest
container: google/cloud-sdk
env:
GCLOUD_SERVICE_ACCOUNT_JSON: ${{ secrets.GCLOUD_SERVICE_ACCOUNT_JSON }}
SNAPSHOT_REGISTRY: ${{ secrets.SNAPSHOT_REGISTRY }}
COMMIT_TAG: ${{ github.sha }}
steps:
- run: echo "COMMIT_TAG=$(echo $COMMIT_TAG | cut -c 1-7)" >> $GITHUB_ENV
- run: echo $GCLOUD_SERVICE_ACCOUNT_JSON | base64 -d | docker login -u _json_key --password-stdin https://us-docker.pkg.dev
- uses: actions/checkout@v3
- run: make build
- run: make push
# push container image
tag-release:
if: ${{ github.ref_type == 'tag' }}
needs:
- build-container
runs-on: ubuntu-latest
container: google/cloud-sdk
env:
GCLOUD_SERVICE_ACCOUNT_JSON: ${{ secrets.GCLOUD_SERVICE_ACCOUNT_JSON }}
SNAPSHOT_REGISTRY: ${{ secrets.SNAPSHOT_REGISTRY }}
RELEASE_REGISTRY: ${{ secrets.RELEASE_REGISTRY }}
COMMIT_TAG: ${{ github.sha }}
RELEASE_TAG: ${{ github.ref_name }}
steps:
- run: echo "COMMIT_TAG=$(echo $COMMIT_TAG | cut -c 1-7)" >> $GITHUB_ENV
- run: echo $GCLOUD_SERVICE_ACCOUNT_JSON | base64 -d > /tmp/service-account.json
- run: gcloud auth activate-service-account --key-file=/tmp/service-account.json
- uses: actions/checkout@v3
- run: make release
# terraform checks