-
Notifications
You must be signed in to change notification settings - Fork 2
232 lines (223 loc) · 8.69 KB
/
pdfbygger-brevbaker.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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
name: "Build and deploy brevbaker and pdf-bygger"
on:
workflow_dispatch:
pull_request:
paths:
- "build.gradle.kts"
- "gradle.properties"
- "template-model-generator/**"
- "pensjon-brevbaker/**"
- "pdf-bygger/**"
- ".github/workflows/pdfbygger-brevbaker.yml"
push:
branches:
- "main"
paths:
- "build.gradle.kts"
- "gradle.properties"
- "template-model-generator/**"
- "pensjon-brevbaker/**"
- "pdf-bygger/**"
- ".github/workflows/pdfbygger-brevbaker.yml"
env:
"IMAGE_BREVBAKER": "ghcr.io/${{ github.repository }}/pensjon-brevbaker:${{ github.sha }}"
"IMAGE_PDF_BUILDER": "ghcr.io/${{ github.repository }}/pensjon-pdf-bygger:${{ github.sha }}"
jobs:
"build-brevbaker":
name: "build brevbaker"
runs-on: "ubuntu-latest"
steps:
- uses: "actions/checkout@v3"
- uses: "gradle/wrapper-validation-action@v1"
- uses: "actions/cache@v3"
with:
"path": "~/.gradle/caches"
"key": "${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle.kts') }}"
"restore-keys": "${{ runner.os }}-gradle-"
- uses: "actions/setup-java@v3"
with:
"distribution": "temurin"
"java-version": "17"
- name: "compile and run tests"
run: |
./gradlew :brevbaker-api-model-common:publishToMavenLocal
./gradlew :pensjon-brevbaker-api-model:publishToMavenLocal
./gradlew :pensjon-brevbaker:build
env:
"GITHUB_TOKEN": "${{ secrets.GITHUB_TOKEN }}"
- name: "Build and publish Docker image"
run: "docker build --pull --tag ${IMAGE_BREVBAKER} pensjon-brevbaker && echo $GITHUB_TOKEN | docker login\
\ --username $GITHUB_REPOSITORY --password-stdin https://ghcr.io\
\ && docker push ${IMAGE_BREVBAKER}"
env:
"GITHUB_TOKEN": "${{ secrets.GITHUB_TOKEN }}"
"build-pdfbygger":
name: "build pdfbygger"
runs-on: "ubuntu-latest"
steps:
- uses: "actions/checkout@v3"
- uses: "gradle/wrapper-validation-action@v1"
- uses: "actions/cache@v3"
with:
"path": "~/.gradle/caches"
"key": "${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle.kts') }}"
"restore-keys": "${{ runner.os }}-gradle-"
- uses: "actions/setup-java@v3"
with:
"distribution": "temurin"
"java-version": "17"
- name: "compile and run tests"
run: "./gradlew :pdf-bygger:build"
- name: "Build and publish Docker image"
run: "docker build --pull --tag ${IMAGE_PDF_BUILDER} pdf-bygger && echo $GITHUB_TOKEN | docker login\
\ --username $GITHUB_REPOSITORY --password-stdin https://ghcr.io\
\ && docker push ${IMAGE_PDF_BUILDER}"
env:
"GITHUB_TOKEN": "${{ secrets.GITHUB_TOKEN }}"
changes:
runs-on: ubuntu-latest
outputs:
latex: ${{ steps.changes.outputs.latex }}
steps:
- uses: actions/checkout@v3
- uses: dorny/paths-filter@v2
id: changes
with:
filters: |
latex:
- 'pensjon-brevbaker/src/main/resources/latex/**'
runIntegrationTests:
name: "Integration tests"
needs: [ build-brevbaker, build-pdfbygger, changes ]
services:
pdf-bygger:
ports:
- 8081:8080
image: "ghcr.io/${{ github.repository }}/pensjon-pdf-bygger:${{ github.sha }}"
credentials:
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
brevbaker:
env:
PDF_BUILDER_URL: "http://pdf-bygger:8080"
AZURE_OPENID_CONFIG_JWKS_URI: "http://vtp-pensjon:8060/rest/isso/oauth2/connect/jwk_uri"
AZURE_OPENID_CONFIG_ISSUER: "https://login.microsoftonline.com/966ac572-f5b7-4bbe-aa88-c76419c0f851/v2.0"
AZURE_APP_CLIENT_ID: "brevbaker-123"
JAVA_OPTS: "-Dio.ktor.development=true"
ports:
- 8080:8080
image: "ghcr.io/${{ github.repository }}/pensjon-brevbaker:${{ github.sha }}"
credentials:
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
runs-on: ubuntu-latest
steps:
- uses: "actions/checkout@v3"
- uses: "actions/cache@v3"
with:
"path": "~/.gradle/caches"
"key": "${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle.kts') }}"
"restore-keys": "${{ runner.os }}-gradle-"
- uses: "actions/setup-java@v3"
with:
"distribution": "temurin"
"java-version": "17"
- name: "run integration tests"
run: |
./gradlew :brevbaker-api-model-common:publishToMavenLocal
./gradlew :pensjon-brevbaker-api-model:publishToMavenLocal
./gradlew :pensjon-brevbaker:integrationTest
env:
"GITHUB_TOKEN": "${{ secrets.GITHUB_TOKEN }}"
- name: Publish Test Report
if: ${{ always() }}
uses: scacap/action-surefire-report@v1
with:
fail_if_no_tests: true
fail_on_test_failures: true
report_paths: '**/build/test-results/integrationTest/TEST-*.xml'
- name: Convert visual-test pdfs
uses: jruipinto/ImageMagick-action@v1
if: ${{ needs.changes.outputs.latex == 'true' }}
with:
command: mogrify -path pensjon-brevbaker/build/test_visual -format png -background white -alpha remove -alpha off -density 300 -quality 85 pensjon-brevbaker/build/test_visual/pdf/*.pdf
- uses: actions/setup-node@v3
if: ${{ needs.changes.outputs.latex == 'true' }}
with:
node-version: '14'
- run: npm install --save-dev @percy/cli
if: ${{ needs.changes.outputs.latex == 'true' }}
- name: Publish visual-tests to percy
if: ${{ needs.changes.outputs.latex == 'true' }}
run: |
npx percy upload pensjon-brevbaker/build/test_visual/ > percy.log
cat percy.log
cat percy.log | grep -e "build #[0-9]\+:" | sed 's/^.*build #[0-9]\+: //g' > percy-build-url
env:
PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }}
- name: Comment percy review link
uses: peter-evans/create-or-update-comment@v3
if: ${{ needs.changes.outputs.latex == 'true' && github.event_name == 'pull_request' }}
with:
issue-number: ${{ github.event.number }}
body-path: percy-build-url
"deployBrevbakerToDev":
name: "Deploy brevbaker to dev"
if: (github.event_name == 'push' && github.ref == 'refs/heads/main') || github.event_name == 'workflow_dispatch'
needs: "runIntegrationTests"
runs-on: "ubuntu-latest"
steps:
- uses: "actions/checkout@v3"
- name: "Deploy to DEV"
uses: "nais/deploy/actions/deploy@v1"
env:
"APIKEY": "${{ secrets.NAIS_DEPLOY_APIKEY }}"
"CLUSTER": "dev-gcp"
"RESOURCE": "pensjon-brevbaker/.nais/nais.yaml"
"VAR": image=${{ env.IMAGE_BREVBAKER }}
"VARS": "pensjon-brevbaker/.nais/dev.yaml"
"deployPdfByggerToDev":
name: "Deploy pdf-bygger to dev"
if: (github.event_name == 'push' && github.ref == 'refs/heads/main') || github.event_name == 'workflow_dispatch'
needs: "runIntegrationTests"
runs-on: "ubuntu-latest"
steps:
- uses: "actions/checkout@v3"
- name: "Deploy to DEV"
uses: "nais/deploy/actions/deploy@v1"
env:
"APIKEY": "${{ secrets.NAIS_DEPLOY_APIKEY }}"
"CLUSTER": "dev-gcp"
"RESOURCE": "pdf-bygger/.nais/nais.yaml"
"VAR": image=${{ env.IMAGE_PDF_BUILDER }}
"VARS": "pdf-bygger/.nais/dev.yaml"
"deployBrevbakerToProduction":
name: "Deploy brevbaker to production"
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
needs: "runIntegrationTests"
runs-on: "ubuntu-latest"
steps:
- uses: "actions/checkout@v3"
- name: "Deploy to production"
uses: "nais/deploy/actions/deploy@v1"
env:
"APIKEY": "${{ secrets.NAIS_DEPLOY_APIKEY }}"
"CLUSTER": "prod-gcp"
"RESOURCE": "pensjon-brevbaker/.nais/nais.yaml"
"VAR": image=${{ env.IMAGE_BREVBAKER }}
"VARS": "pensjon-brevbaker/.nais/prod.yaml"
"deployPdfByggerToProduction":
name: "Deploy pdf-bygger to production"
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
needs: "runIntegrationTests"
runs-on: "ubuntu-latest"
steps:
- uses: "actions/checkout@v3"
- name: "Deploy to production"
uses: "nais/deploy/actions/deploy@v1"
env:
"APIKEY": "${{ secrets.NAIS_DEPLOY_APIKEY }}"
"CLUSTER": "prod-gcp"
"RESOURCE": "pdf-bygger/.nais/nais.yaml"
"VAR": image=${{ env.IMAGE_PDF_BUILDER }}
"VARS": "pdf-bygger/.nais/prod.yaml"