Skip to content

Klass-forvaltning build and deploy #234

Klass-forvaltning build and deploy

Klass-forvaltning build and deploy #234

name: Klass-forvaltning build and deploy
on:
release:
types: [published]
push:
branches:
- main
paths:
- "klass-forvaltning/**"
- ".nais/**/klass-forvaltning.yaml"
- ".github/workflows/klass-forvaltning-build-and-deploy.yaml"
workflow_dispatch:
inputs:
cluster:
description: "Which cluster to deploy to?"
required: true
default: "test"
type: choice
options:
- test
- prod
jobs:
docker-build:
name: Docker build
permissions:
contents: "read"
id-token: "write"
packages: "read"
runs-on: ubuntu-latest
outputs:
image: ${{ steps.docker-build-push.outputs.image }}
telemetry: ${{ steps.docker-build-push.outputs.telemetry }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '8'
cache: 'maven'
- name: Build with Maven
working-directory: klass-forvaltning
run: mvn --batch-mode --update-snapshots install -DskipTests
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
uses: nais/docker-build-push@v0
id: docker-build-push
with:
team: dapla-metadata
image_suffix: forvaltning
dockerfile: klass-forvaltning/Dockerfile
docker_context: klass-forvaltning
deploy-test:
name: Deploy to test
needs: docker-build
permissions:
contents: "read"
id-token: "write"
packages: "read"
runs-on: ubuntu-latest
if: github.event_name != 'release' || github.event.inputs.cluster == 'test'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Deploy to test cluster
uses: nais/deploy/actions/deploy@v2
env:
CLUSTER: test
RESOURCE: .nais/test/klass-forvaltning.yaml
DEPLOY_SERVER: deploy.ssb.cloud.nais.io:443
WORKLOAD_IMAGE: ${{ needs.docker-build.outputs.image }}
TELEMETRY: ${{ needs.docker-build.outputs.telemetry }}
deploy-prod:
name: Deploy to prod
needs: docker-build
permissions:
contents: "read"
id-token: "write"
packages: "read"
runs-on: ubuntu-latest
if: github.event_name == 'release' || github.event.inputs.cluster == 'prod'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Deploy to prod cluster
uses: nais/deploy/actions/deploy@v2
env:
CLUSTER: prod
RESOURCE: .nais/prod/klass-forvaltning.yaml
DEPLOY_SERVER: deploy.ssb.cloud.nais.io:443
WORKLOAD_IMAGE: ${{ needs.docker-build.outputs.image }}
TELEMETRY: ${{ needs.docker-build.outputs.telemetry }}