Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
129 changes: 107 additions & 22 deletions .github/workflows/sandbox.yml
Original file line number Diff line number Diff line change
@@ -1,58 +1,143 @@
name: Build, push, and deploy

name: 'Build and deploy sandbox'

on:
push:
branches:
- sandbox
workflow_call:

env:
docker_image: docker.pkg.github.com/${{ github.repository }}/navansatt:${{ github.sha }}
IMAGE_BASE: ghcr.io/${{ github.repository }}

jobs:
build:
name: Build and push Docker container
name: "Build Navansatt"
permissions:
contents: "read"
checks: "write"
id-token: "write"
packages: "write"
runs-on: ubuntu-latest
timeout-minutes: 30
outputs:
version: ${{ steps.version.outputs.version }}
image: "${{ steps.login.outputs.registry }}/${{ github.repository }}/navansatt:${{ env.VERSION }}"
image-digest: "${{ steps.login.outputs.registry }}/${{ github.repository }}/navansatt:@${{ steps.build_push.outputs.digest }}"
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
- uses: actions/checkout@v4
with:
path: ~/.m2
key: "${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}"
ref: 'sandbox'
- name: Set version
id: version
shell: bash
run: |
TIME=$(TZ="Europe/Oslo" date +%Y.%m.%d-%H.%M)
COMMIT=$(git rev-parse --short=12 HEAD)
export VERSION="$TIME-$COMMIT-sandbox"
echo "Building version $VERSION"
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
echo "::set-output name=yearweek::$(date +'%Y-%W')"
- name: Cache local Maven repository
uses: actions/cache@v4
with:
path: |
~/.m2/repository/*/*
!~/.m2/repository/no/nav
key: ${{ runner.os }}-maven-${{ steps.version.outputs.yearweek }}-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- uses: actions/setup-java@v1
${{ runner.os }}-maven-${{ steps.version.outputs.yearweek }}-
- uses: actions/setup-java@v4
with:
java-version: 14
distribution: 'temurin'
java-version: '17'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Antar at jeg kan bumpe til temurin:17?
Så at dockerfila kjører på det hvertfall.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ja det burde gå bra

- uses: docker/setup-buildx-action@v3

- name: Build
shell: bash
run: |
mvn versions:set -DnewVersion="$VERSION" -DgenerateBackupPoms=false -Pgithub-action --batch-mode -DprocessAllModules
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ikke legg til denne. Kan forklare på ZOom

mvn clean install
- name: Build and publish Docker image
# mvn clean verify -Pgithub-action -Dmaven.wagon.http.retryHandler.count=3 -Dsurefire.rerunFailingTestsCount=2 -Dlogback.configurationFile="${GITHUB_WORKSPACE}/.github/logback-github.xml" --batch-mode --fail-at-end -T 1.5C
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Her trenger jeg en prat. mvn clean install vs. den lange der med logback osv osv.

Copy link
Contributor

@pcmoen pcmoen Oct 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mvn clean install er stort sett alltid feil mer enn nødvendig 😊. wagon retry kom på den tiden GitHub var sykt ustabil

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Om du skal bytte ut noe så holder det nok å bytte til mvn clean verify

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
docker build --tag ${docker_image} .
docker login docker.pkg.github.com -u ${GITHUB_REPOSITORY} -p ${GITHUB_TOKEN}
docker push ${docker_image}
TZ: "Europe/Oslo"

- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: NAIS login
uses: nais/login@v0
id: login
with:
project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }}
identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }}
team: teampensjon
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Litt usikker på teampensjon vs. pensjondeployer og hva som er korrekt her.
Appen kjører jo i -ns teampensjon, så tror teampensjon er korrekt.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merge og se hva som skjer 😄


- name: "Build and publish navansatt Docker image"
id: build_push
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile
tags: "${{ steps.login.outputs.registry }}/${{ github.repository }}/navansatt:${{ env.VERSION }},${{ steps.login.outputs.registry }}/${{ github.repository }}/navansatt:sandbox"
push: true
cache-from: |
"type=registry,ref=${{ steps.login.outputs.registry }}/${{ github.repository }}/navansatt:sandbox"
"type=registry,ref=${{ steps.login.outputs.registry }}/${{ github.repository }}/navansatt:main"
cache-to: type=inline

deploy:
name: Deploy to NAIS
name: "Deploy"
permissions:
contents: "read"
id-token: "write"
needs: build
if: github.ref == 'refs/heads/sandbox'
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
ref: 'sandbox'
- uses: nais/deploy/actions/deploy@v2
name: Dev deploy
name: "Deploy to NAIS"
env:
CLUSTER: dev-fss
RESOURCE: nais/nais-dev.yml
VAR: image=${{ env.docker_image }}
IMAGE: "${{ needs.build.outputs.image }}"
CLUSTER: dev-fss
TIMEOUT: 10m

attest-sign:
permissions:
contents: read
id-token: write
needs: [build]
runs-on: 'ubuntu-latest'
steps:
- uses: actions/checkout@v4
- name: NAIS login
uses: nais/login@v0
id: login
with:
project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }}
identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }}
team: teampensjon
- name: 'Generate SBOM'
uses: aquasecurity/[email protected]
with:
scan-type: 'image'
format: 'cyclonedx'
output: 'trivy-results.cyclonedx'
image-ref: "${{ needs.build.outputs.image-digest }}"
- name: Attest and sign image
id: attest-sign
uses: nais/attest-sign@v1
with:
image_ref: "${{ needs.build.outputs.image-digest }}"
sbom: "trivy-results.cyclonedx"
23 changes: 20 additions & 3 deletions nais/nais-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,40 @@ spec:
rules:
- application: pensjon-pen-q0
namespace: pensjon-q0
cluster: dev-fss
- application: pensjon-pen-q1
namespace: pensjon-q1
cluster: dev-fss
- application: pensjon-pen-q2
namespace: pensjon-q2
cluster: dev-fss
- application: pensjon-pen-q5
namespace: pensjon-q5
cluster: dev-fss
- application: pensjon-psak-q0
namespace: pensjon-q0
cluster: dev-fss
- application: pensjon-psak-q1
namespace: pensjon-q1
cluster: dev-fss
- application: pensjon-psak-q2
namespace: pensjon-q2
cluster: dev-fss
- application: pensjon-psak-q5
namespace: pensjon-q5
cluster: dev-fss
- application: pensjon-psak-q0
namespace: pensjon-q0
cluster: dev-gcp
- application: pensjon-psak-q1
namespace: pensjon-q1
cluster: dev-gcp
- application: pensjon-psak-q2
namespace: pensjon-q2
cluster: dev-gcp
- application: pensjon-psak-q5
namespace: pensjon-q5
cluster: dev-gcp
- application: etterlatte-brev-api
namespace: etterlatte
cluster: dev-gcp
Expand All @@ -71,9 +91,6 @@ spec:
- application: skribenten-backend-lokal
namespace: pensjonsbrev
cluster: dev-gcp
- application: pensjon-psak-q2
namespace: pensjon-q2
cluster: dev-gcp
azure:
application:
enabled: true
Expand Down
4 changes: 4 additions & 0 deletions nais/nais-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ spec:
namespace: pensjondeployer
- application: pensjon-psak
namespace: pensjondeployer
cluster: prod-fss
- application: pensjon-psak
namespace: pensjondeployer
cluster: prod-gcp
- application: etterlatte-brev-api
namespace: etterlatte
cluster: prod-gcp
Expand Down
53 changes: 0 additions & 53 deletions nais/nais-test.yml

This file was deleted.

4 changes: 2 additions & 2 deletions src/main/kotlin/no/nav/navansatt/mainModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ fun Application.mainModule(
install(CallLogging) {
level = Level.INFO
filter { call -> !call.request.path().matches(Regex(".*/isready|.*/isalive|.*/metrics")) }
callIdMdc("X-Correlation-ID")
callIdMdc("correlationId")
}
install(CallId) {
retrieveFromHeader("X-Correlation-ID")
retrieveFromHeader("correlationId")
generate { UUID.randomUUID().toString() }
}
install(Locations)
Expand Down