Skip to content

Build-Deploy-Preprod #1242

Build-Deploy-Preprod

Build-Deploy-Preprod #1242

name: Build-Deploy-Preprod
on:
workflow_dispatch:
jobs:
build-jar-docker:
# if: github.event.pull_request.draft == false
name: Bygg app/image, push til github
runs-on: ubuntu-latest
permissions:
contents: "read"
id-token: "write"
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-java@v4
with:
java-version: 21
distribution: 'temurin'
cache: 'maven'
- name: Bygg med maven u/test
env:
SONAR_PROJECTKEY: ${{ secrets.SONAR_PROJECTKEY }}
SONAR_LOGIN: ${{ secrets.SONAR_LOGIN }}
GITHUB_USERNAME: x-access-token
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: mvn -B --no-transfer-progress package verify -Dmaven.test.skip=true --settings .m2/maven-settings.xml -DtrimStackTrace=false --file pom.xml -Dchangelist= -Dsha1=-$TIMESTAMP-$(echo $GITHUB_SHA | cut -c1-7)
- uses: nais/docker-build-push@v0
id: docker-push
with:
team: tilbake
push_image: true
tag: ${{ github.sha }}
dockerfile: Dockerfile
docker_context: .
project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }}
identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }}
outputs:
image: ${{ steps.docker-push.outputs.image }}
run-junit:
name: Kjøre junit tester
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-java@v4
with:
java-version: 21
distribution: 'temurin'
cache: 'maven'
- name: Bygg med maven + sonar
env:
SONAR_PROJECTKEY: ${{ secrets.SONAR_PROJECTKEY }}
SONAR_LOGIN: ${{ secrets.SONAR_LOGIN }}
GITHUB_USERNAME: x-access-token
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: mvn -B --no-transfer-progress package --settings .m2/maven-settings.xml -DtrimStackTrace=false --file pom.xml -Dchangelist= -Dsha1=-$TIMESTAMP-$(echo $GITHUB_SHA | cut -c1-7)
run-e2e:
name: Kjør e2e tester
permissions:
contents: "read"
id-token: "write"
runs-on: ubuntu-latest
needs: build-jar-docker
steps:
- name: Login GAR
uses: nais/login@v0
with:
project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }}
identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }}
team: tilbake
- name: Checkout e2e tests
if: "!contains(github.event.head_commit.message, 'e2e skip')"
uses: actions/checkout@v4
with:
ref: "main"
repository: navikt/familie-tilbake-e2e
token: ${{ secrets.READER_TOKEN }}
path: tilbake-e2e
- name: Setter riktig familie-tilbake versjon i e2e tester
if: "!contains(github.event.head_commit.message, 'e2e skip')"
run: sed -i 's/europe-north1-docker.pkg.dev\/nais-management-233d\/teamfamilie\/familie-tilbake:latest/europe-north1-docker.pkg.dev\/nais-management-233d\/tilbake\/familie-tilbake:${{ github.sha }}/g' tilbake-e2e/e2e/docker-compose.yml
- name: Set up Java 21
uses: actions/setup-java@v4
with:
java-version: 21
distribution: 'temurin'
cache: 'maven'
- name: Start alle apper (e2e)
env:
INTEGRASJONER_CLIENT_ID: ${{ secrets.INTEGRASJONER_CLIENT_ID }}
INTEGRASJONER_CLIENT_SECRET: ${{ secrets.INTEGRASJONER_CLIENT_SECRET }}
INTEGRASJONER_INFOTRYGD_KS_SCOPE: ${{ secrets.INTEGRASJONER_INFOTRYGD_KS_SCOPE }}
INTEGRASJONER_AAD_GRAPH_SCOPE: ${{ secrets.INTEGRASJONER_AAD_GRAPH_SCOPE }}
TILBAKE_CLIENT_ID: ${{ secrets.TILBAKE_CLIENT_ID }}
TILBAKE_CLIENT_SECRET: ${{ secrets.TILBAKE_CLIENT_SECRET }}
TILBAKE_FRONTEND_CLIENT_ID: ${{ secrets.TILBAKE_FRONTEND_CLIENT_ID }}
INTEGRASJONER_SCOPE: ${{ secrets.INTEGRASJONER_SCOPE }}
HISTORIKK_CLIENT_ID: ${{ secrets.HISTORIKK_CLIENT_ID }}
HISTORIKK_CLIENT_SECRET: ${{ secrets.HISTORIKK_CLIENT_SECRET }}
if: "!contains(github.event.head_commit.message, 'e2e skip')"
run: cd tilbake-e2e/e2e; ./e2e.sh
- name: Kjør tester (e2e)
env:
GITHUB_USERNAME: x-access-token
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TILBAKE_CLIENT_ID: ${{ secrets.TILBAKE_CLIENT_ID }}
TILBAKE_CLIENT_SECRET: ${{ secrets.TILBAKE_CLIENT_SECRET }}
HISTORIKK_CLIENT_ID: ${{ secrets.HISTORIKK_CLIENT_ID }}
HISTORIKK_CLIENT_SECRET: ${{ secrets.HISTORIKK_CLIENT_SECRET }}
if: "!contains(github.event.head_commit.message, 'e2e skip')"
run: cd tilbake-e2e/autotest; mvn -B --no-transfer-progress --settings .m2/maven-settings.xml -Dtest="**" test
- name: Samle Docker-logs ved feil
if: failure()
uses: jwalton/gh-docker-logs@v2
with:
dest: './logs'
- name: Tar logs
if: failure()
run: tar cvzf ./logs.tgz ./logs
- name: Laste opp logs til GitHub
uses: actions/upload-artifact@master
if: failure()
with:
name: docker-logs-${{ github.run_number }}.tgz
path: ./logs.tgz
retention-days: 2
deploy-to-dev:
name: Deploy til dev-gcp
runs-on: ubuntu-latest
needs: [ build-jar-docker, run-junit ]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Deploy til dev-gcp
uses: nais/deploy/actions/deploy@v2
env:
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }}
CLUSTER: dev-gcp
RESOURCE: .deploy/nais/app-dev-gcp.yaml
VAR: image=${{ needs.build-jar-docker.outputs.image }}