-
Notifications
You must be signed in to change notification settings - Fork 2
203 lines (181 loc) · 5.71 KB
/
deploy-to-dev.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
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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
name: Manual deploy to dev
on:
workflow_call:
inputs:
e2e_tag:
description: "Tag of E2E image to run"
required: false
default: latest
type: string
secrets:
NAIS_WORKLOAD_IDENTITY_PROVIDER:
description: "Identity provider for nais/docker-build-push"
required: true
READER_TOKEN:
description: "Token for @navikt NPM registry (@navikt/nav-dekoratoren-moduler)"
required: true
workflow_dispatch:
inputs:
e2e_tag:
description: "Tag of E2E image to run"
required: false
default: latest
type: string
run-name: Dev deploy of ${{ github.ref_name }}
jobs:
build-frontend:
name: Build frontend
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./frontend
permissions:
contents: read
id-token: write
concurrency:
group: build
cancel-in-progress: true
outputs:
artifact-id: ${{ steps.upload.outputs.artifact-id }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: latest
registry-url: "https://npm.pkg.github.com/"
scope: "@navikt"
- name: Install frontend dependencies
run: bun install --frozen-lockfile
env:
BUN_AUTH_TOKEN: ${{ secrets.READER_TOKEN }}
- name: Test frontend
run: bun test
- name: Build frontend
shell: bash
env:
VERSION: ${{ github.sha }}
run: bun run build
- name: Store index.html artifact
id: upload
uses: actions/upload-artifact@v4
with:
name: index.html
path: ./dist/index.html
- name: Upload static files to CDN
uses: nais/deploy/actions/cdn-upload/v2@master
with:
team: klage
source: ./frontend/dist/assets/
destination: klang
project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }}
identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }}
build-server:
name: Build frontend
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./server
permissions:
contents: read
id-token: write
concurrency:
group: build
cancel-in-progress: true
outputs:
artifact-id: ${{ steps.upload.outputs.artifact-id }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: latest
registry-url: "https://npm.pkg.github.com/"
scope: "@navikt"
- name: Install server dependencies
env:
BUN_AUTH_TOKEN: ${{ secrets.READER_TOKEN }}
run: bun install --frozen-lockfile
- name: Test server
run: bun test
- name: Build server
run: bun run build
- name: Store server files artifact
id: upload
uses: actions/upload-artifact@v4
with:
name: server
path: ./dist
build-image:
name: Build Docker image
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
needs: [build-frontend, build-server]
outputs:
image: ${{ steps.docker-build-push.outputs.image }}
steps:
- name: Generate version number
id: version
run: echo "version=$(TZ="Europe/Oslo" git show -s --format=%cd --date='format-local:%Y-%m-%dT%H:%M:%S')" >> "$GITHUB_OUTPUT"
- name: Fetch index.html artifact
uses: actions/download-artifact@v4
with:
name: ${{ needs.build-frontend.outputs.artifact-id }}
path: ./frontend/dist/index.html
- name: Fetch server files artifact
uses: actions/download-artifact@v4
with:
name: ${{ needs.build-server.outputs.artifact-id }}
path: ./server/dist
- name: Build & push Docker image
uses: nais/docker-build-push@v0
id: docker-build-push
with:
team: klage # required
tag: ${{ github.sha }} # optional
push_image: true # optional, default true
dockerfile: Dockerfile # optional, default Dockerfile
docker_context: . # optional, default .
image_suffix: frontend # optional, default empty
cache_from: type=gha # optional, default type=gha
cache_to: type=gha,mode=max # optional, default type=gha,mode=max
identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }} # required, but is defined as an organization secret
project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }} # required, but is defined as an organization variable
build_args: |
VERSION=${{ steps.version.outputs.version }}
deploy_to_dev:
name: Deploy
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
needs: build-image
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Deploy to dev
uses: nais/deploy/actions/deploy@v2
env:
CLUSTER: dev-gcp
VARS: nais/dev.yaml
RESOURCE: nais/nais.yaml
VAR: image=${{ needs.build-image.outputs.image }}
e2e_test:
name: E2E
needs: deploy_to_dev
if: false # TODO: Remove this line when E2E tests are available
permissions:
contents: read
id-token: write
runs-on: ubuntu-latest
steps:
- name: E2E
uses: navikt/klang-e2e-tests/.github/actions/run@main
with:
e2e_tag: ${{ inputs.e2e_tag }}
nais_management_project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }}
nais_workload_identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }}