Build and deploy app | "Oppdater avhengigheter" #466
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 app | |
run-name: Build and deploy app | "${{ github.event.head_commit.message }}" | |
on: | |
push: | |
branches: | |
- master | |
- verif-v5-token-validation-support | |
paths-ignore: | |
- '**.md' | |
- '**/**.md' | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
docker-build-push: | |
name: Build, test and push docker image | |
permissions: | |
contents: write | |
id-token: write | |
runs-on: ubuntu-latest | |
timeout-minutes: 10 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-java@v4 | |
with: | |
distribution: temurin | |
java-version: 21 | |
cache: maven | |
- name: Run tests | |
run: mvn test | |
- name: Build jar with Maven | |
run: mvn package -DskipTests | |
- name: Submit Dependency Snapshot | |
uses: advanced-security/[email protected] | |
- uses: nais/docker-build-push@v0 | |
id: docker-push | |
env: | |
TRIVY_JAVA_DB_REPOSITORY: "public.ecr.aws/aquasecurity/trivy-java-db:1" | |
with: | |
team: arbeidsgiver | |
identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }} | |
project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }} | |
outputs: | |
image: ${{ steps.docker-push.outputs.image }} | |
deploy-to-dev: | |
name: Deploy to dev-fss | |
needs: docker-build-push | |
runs-on: ubuntu-latest | |
timeout-minutes: 5 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: nais/deploy/actions/deploy@v1 | |
env: | |
CLUSTER: dev-fss | |
IMAGE: ${{ needs.docker-build-push.outputs.image }} | |
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }} | |
RESOURCE: nais/dev.yaml | |
deploy-to-prod: | |
name: Deploy to prod-fss | |
needs: docker-build-push | |
if: github.ref == 'refs/heads/master' | |
runs-on: ubuntu-latest | |
timeout-minutes: 5 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: nais/deploy/actions/deploy@v1 | |
env: | |
CLUSTER: prod-fss | |
IMAGE: ${{ needs.docker-build-push.outputs.image }} | |
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }} | |
RESOURCE: nais/prod.yaml | |
trivy-scan: | |
name: Scanner docker image med Trivy | |
if: github.ref == 'refs/heads/master' | |
needs: docker-build-push | |
permissions: | |
contents: read # to write sarif | |
security-events: write # push sarif to GitHub security | |
id-token: write # for nais/login | |
runs-on: ubuntu-latest | |
steps: | |
- uses: navikt/pia-actions/trivy-scan@v1 # https://github.com/navikt/pia-actions/tree/main/trivy-scan | |
with: | |
image: ${{ needs.docker-build-push.outputs.image }} | |
team: arbeidsgiver | |
project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }} | |
identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }} |