Merge pull request #1504 from navikt/nais-api-v1 #249
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: 'deploy: backend' | |
on: | |
push: | |
branches: | |
- 'main' | |
paths: | |
- '.github/workflows/deploy-backend.yaml' | |
- 'apps/backend/**' | |
workflow_dispatch: | |
env: | |
IMAGE: ghcr.io/${{ github.repository }}/teambackend:${{ github.sha }} | |
defaults: | |
run: | |
working-directory: apps/backend | |
jobs: | |
build: | |
name: Backend - build and push docker | |
permissions: | |
contents: read | |
id-token: write | |
runs-on: ubuntu-latest | |
outputs: | |
image: ${{ steps.docker-build-push.outputs.image }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Cache Dependencies | |
uses: actions/cache@v4 | |
with: | |
path: ~/.m2/repository | |
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | |
restore-keys: ${{ runner.os }}-maven- | |
- name: Set up JDK | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: '21' | |
- name: Build | |
run: mvn compile --batch-mode | |
- name: Test and Package | |
run: mvn package --batch-mode | |
- name: Build and push Docker container | |
uses: nais/docker-build-push@v0 | |
id: docker-build-push | |
with: | |
team: org | |
docker_context: apps/backend | |
dockerfile: apps/backend/Dockerfile | |
identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }} | |
project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }} | |
deploy-preprod: | |
name: Backend - deploy Dev GCP | |
needs: build | |
runs-on: ubuntu-latest | |
permissions: | |
contents: "read" | |
id-token: "write" | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: nais/deploy/actions/deploy@v2 | |
env: | |
CLUSTER: dev-gcp | |
RESOURCE: apps/backend/nais/backend-dev-gcp.yaml | |
VAR: image=${{needs.build.outputs.image}} | |
deploy-prod: | |
name: Backend - deploy Prod GCP | |
needs: build | |
if: github.ref == 'refs/heads/main' | |
runs-on: ubuntu-latest | |
permissions: | |
contents: "read" | |
id-token: "write" | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: nais/deploy/actions/deploy@v2 | |
env: | |
CLUSTER: prod-gcp | |
RESOURCE: apps/backend/nais/backend-prod-gcp.yaml | |
VAR: image=${{ needs.build.outputs.image }} |