EY-2578: Testar alle etterlatte-brevmalar automatisk til både HTML, PDF og for delmalar JSON #759
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |