v4.3.0 #312
Workflow file for this run
This file contains hidden or 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: Klass-api build and deploy | |
| on: | |
| release: | |
| types: [ published ] | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - "klass-api/**" | |
| - "klass-shared/**" | |
| - ".nais/**/klass-api.yaml" | |
| - ".github/workflows/klass-api-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 }} | |
| prod-config-changed: ${{ steps.prod-config-changed.outputs.changed != 'non-inputs' }} | |
| test-config-changed: ${{ steps.test-config-changed.outputs.changed != 'non-inputs' }} | |
| only-config-changed: ${{ steps.changed-files.outputs.changed == 'only-inputs'}} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - uses: actions/setup-java@v4 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '17' | |
| cache: 'maven' | |
| - name: Check what changed | |
| id: changed-files | |
| uses: "nais/what-changed@main" | |
| with: | |
| files: .nais/**/klass-api.yaml | |
| - name: Check for test config changes | |
| id: test-config-changed | |
| uses: "nais/what-changed@main" | |
| with: | |
| files: .nais/test/klass-api.yaml | |
| - name: Check for prod config changes | |
| id: prod-config-changed | |
| uses: "nais/what-changed@main" | |
| with: | |
| files: .nais/prod/klass-api.yaml | |
| - name: Build with Maven | |
| if: steps.changed-files.outputs.changed != 'only-inputs' || github.event.inputs.cluster == 'test' || github.event.inputs.cluster == 'prod' | |
| run: mvn --batch-mode --update-snapshots install | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and push | |
| if: steps.changed-files.outputs.changed != 'only-inputs' || github.event.inputs.cluster == 'test' || github.event.inputs.cluster == 'prod' | |
| uses: nais/docker-build-push@v0 | |
| id: docker-build-push | |
| with: | |
| team: dapla-metadata | |
| image_suffix: api | |
| dockerfile: klass-api/Dockerfile | |
| docker_context: klass-api | |
| 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' || needs.docker-build.outputs.test-config-changed == 'true' | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - uses: nais/deploy/actions/deploy@v2 | |
| env: | |
| CLUSTER: test | |
| RESOURCE: .nais/test/klass-api.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' || (needs.docker-build.outputs.prod-config-changed == 'true' && needs.docker-build.outputs.only-config-changed == 'true') | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - uses: nais/deploy/actions/deploy@v2 | |
| env: | |
| CLUSTER: prod | |
| RESOURCE: .nais/prod/klass-api.yaml | |
| DEPLOY_SERVER: deploy.ssb.cloud.nais.io:443 | |
| WORKLOAD_IMAGE: ${{ needs.docker-build.outputs.image }} | |
| TELEMETRY: ${{ needs.docker-build.outputs.telemetry }} |