-
Notifications
You must be signed in to change notification settings - Fork 0
184 lines (157 loc) · 4.87 KB
/
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
183
184
name: Build and deploy
on: [push]
env:
IMAGE: ghcr.io/${{ github.repository }}:${{ github.sha }}
LATEST_IMAGE: ghcr.io/${{ github.repository }}:latest
jobs:
install:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Cache node_modules
uses: actions/cache@v3
id: node_modules
with:
path: ./node_modules
key: modules-${{ hashFiles('package-lock.json') }}
- uses: actions/setup-node@v3
if: steps.node_modules.outputs.cache-hit != 'true'
with:
node-version: "18.x"
cache: "npm"
registry-url: "https://npm.pkg.github.com"
- run: npm ci --ignore-scripts
if: steps.node_modules.outputs.cache-hit != 'true'
env:
NODE_AUTH_TOKEN: ${{ secrets.READER_TOKEN }}
test:
needs: [install]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: "18.x"
- name: Cache node_modules
uses: actions/cache@v3
with:
path: ./node_modules
key: modules-${{ hashFiles('package-lock.json') }}
- run: npm run test
playwright:
needs: [install]
timeout-minutes: 1
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Cache node_modules
uses: actions/cache@v3
id: node_modules
with:
path: ./node_modules
key: modules-${{ hashFiles('package-lock.json') }}
- uses: actions/setup-node@v3
if: steps.node_modules.outputs.cache-hit != 'true'
with:
node-version: "18.x"
cache: "npm"
registry-url: "https://npm.pkg.github.com"
- name: "Install dependencies"
run: npm ci --ignore-scripts
if: steps.node_modules.outputs.cache-hit != 'true'
- name: Store Playwright's Version
run: |
PLAYWRIGHT_VERSION=$(npm ls @playwright/test | grep @playwright | sed 's/.*@//')
echo "Playwright's Version: $PLAYWRIGHT_VERSION"
echo "PLAYWRIGHT_VERSION=$PLAYWRIGHT_VERSION" >> $GITHUB_ENV
- name: Cache Chromium browser for Playwright's Version
id: cache-chromium-browser
uses: actions/cache@v3
with:
path: ~/.cache/ms-playwright
key: chromium-with-playwright-version-${{ env.PLAYWRIGHT_VERSION }}
- name: Install Chromium browser
if: steps.cache-chromium-browser.outputs.cache-hit != 'true'
run: npx playwright install chromium --with-deps
- name: Run Playwright Tests
run: npm run playwright:verbose
- name: Store Artifacts from Failed Tests
if: failure()
uses: actions/upload-artifact@v2
with:
name: test-results
path: test-results/
retention-days: 7
build:
needs: [install]
runs-on: ubuntu-latest
permissions:
packages: write
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: "18.x"
- name: Cache node_modules
uses: actions/cache@v3
with:
path: ./node_modules
key: modules-${{ hashFiles('package-lock.json') }}
- run: npm run build
# Bygg docker image
- uses: docker/setup-buildx-action@v2
- uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/build-push-action@v3
with:
context: .
push: true
pull: true
tags: ${{ env.IMAGE }},${{ env.LATEST_IMAGE }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Cache static files
uses: actions/cache@v3
with:
path: |
./build
./public
key: ${{ github.sha }}
upload-cdn:
if: github.ref == 'refs/heads/main'
needs: [build, test, playwright]
runs-on: ubuntu-latest
permissions:
contents: "read"
id-token: "write"
steps:
- uses: actions/cache@v3
id: restore-build
with:
path: |
./build
./public
key: ${{ github.sha }}
fail-on-cache-miss: true
- name: Upload static files
uses: navikt/frontend/actions/cdn-upload/v1@main
with:
cdn-team-name: teamdagpenger
source: ./public
destination: "/dp-saksbehandling-frontend/"
deploy-dev:
if: github.ref == 'refs/heads/main'
needs: [build, test, upload-cdn]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: nais/deploy/actions/deploy@v1
env:
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }}
CLUSTER: dev-gcp
RESOURCE: .nais/nais.yaml
VARS: .nais/vars-dev.yaml
PRINT_PAYLOAD: true