-
Notifications
You must be signed in to change notification settings - Fork 0
174 lines (162 loc) · 5.7 KB
/
build-and-test.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
name: Build and test monorepo, and deploy bygger
on: push
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
concurrency: deploy-${{ github.ref }}
jobs:
build-and-test:
name: 'Build and test packages'
runs-on: ubuntu-latest-8-cores
permissions:
contents: 'read'
packages: 'read'
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20.9.0'
cache: 'yarn'
cache-dependency-path: '**/yarn.lock'
registry-url: https://npm.pkg.github.com/
scope: '@navikt'
- name: set timezone
uses: szenius/[email protected]
with:
timezoneLinux: 'Europe/Oslo'
- name: 'Install dependencies'
run: yarn --frozen-lockfile
- name: 'No unstaged changes allowed (changes in yarn.lock?)'
run: git diff --quiet
- name: 'Check types'
run: yarn check-types
- name: 'Build'
run: yarn build
- name: 'Test bygger'
run: yarn test:bygger
- name: 'Test fyllut'
run: yarn test:fyllut
- name: 'Test shared-components'
run: yarn test:shared-components
- name: 'Test shared-domain'
run: yarn test:shared-domain
package-and-push-bygger:
if: github.ref == 'refs/heads/master'
name: 'Package bygger'
runs-on: ubuntu-latest-8-cores
permissions:
contents: 'read'
id-token: 'write'
packages: 'read'
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20.9.0'
cache: 'yarn'
cache-dependency-path: '**/yarn.lock'
registry-url: https://npm.pkg.github.com/
scope: '@navikt'
- name: 'Build application: Bygger'
env:
VITE_GIT_VERSION: ${{ github.sha }}
run: yarn --frozen-lockfile && yarn build
- name: Build and push Docker image for bygger
uses: nais/docker-build-push@v0
id: docker-build-push-bygger
with:
team: skjemadigitalisering
identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }}
project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }}
image_suffix: ${{ github.ref == 'refs/heads/master' && 'bygger' || 'bygger-dev' }}
build_args: |
git_sha=${{ github.sha }}
dockerfile: ./docker/Dockerfile.bygger
docker_context: ./packages
outputs:
image: ${{ steps.docker-build-push-bygger.outputs.image }}
package-and-push-fyllut-base:
if: github.ref == 'refs/heads/master'
name: 'Package fyllut'
runs-on: ubuntu-latest-8-cores
permissions:
contents: 'read'
id-token: 'write'
packages: 'read'
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20.9.0'
cache: 'yarn'
cache-dependency-path: '**/yarn.lock'
registry-url: https://npm.pkg.github.com/
scope: '@navikt'
- name: 'Build application: Fyllut'
env:
VITE_GIT_VERSION: ${{ github.sha }}
run: yarn --frozen-lockfile && yarn build
- name: 'Build and push Docker image: fyllut-base-dev'
uses: nais/docker-build-push@v0
id: docker-build-push-dev
with:
team: skjemadigitalisering
identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }}
project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }}
image_suffix: fyllut-base-dev # base image for dev
build_args: |
git_sha=${{ github.sha }}
dockerfile: ./docker/Dockerfile.fyllut-base
docker_context: ./packages
pull: true
tag: ${{ github.sha }}
- name: 'Build and push Docker image: fyllut-base'
if: github.ref == 'refs/heads/master'
uses: nais/docker-build-push@v0
id: docker-build-push
with:
team: skjemadigitalisering
identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }}
project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }}
image_suffix: fyllut-base # base image for prod
build_args: |
git_sha=${{ github.sha }}
dockerfile: ./docker/Dockerfile.fyllut-base
docker_context: ./packages
pull: true
tag: ${{ github.sha }}
deploy-bygger-to-prod:
name: 'Deploy bygger to prod'
if: github.ref == 'refs/heads/master'
needs: [build-and-test, package-and-push-bygger, package-and-push-fyllut-base]
runs-on: ubuntu-latest
permissions:
id-token: 'write'
steps:
- uses: 'actions/checkout@v4'
- name: 'Deploy to PROD'
uses: 'nais/deploy/actions/deploy@v2'
env:
CLUSTER: 'prod-gcp'
RESOURCE: './.nais/bygger/nais.yaml'
VARS: './.nais/bygger/prod.yaml'
VAR: 'image=${{ needs.package-and-push-bygger.outputs.image }}'
trigger-deploy-fyllut-to-dev:
name: 'Trigger deploy fyllut to dev'
needs: [build-and-test, package-and-push-bygger, package-and-push-fyllut-base]
runs-on: ubuntu-latest
steps:
- name: 'Generate app installation access token'
uses: navikt/github-app-token-generator@v1
id: generate-token
with:
private-key: ${{ secrets.PUBLISHING_APP_PRIVATE_KEY }}
app-id: ${{ secrets.PUBLISHING_APP_ID }}
repo: navikt/skjemautfylling-formio
- name: 'Trigger deploy fyllut to dev'
uses: benc-uk/workflow-dispatch@v1
with:
workflow: 'Trigger dev deploy'
repo: navikt/skjemautfylling-formio
ref: 'dev-deploy'
token: ${{ steps.generate-token.outputs.token }}
inputs: '{ "monorepoGitHash": "${{ github.sha }}" }'