This repository has been archived by the owner on Jul 5, 2024. It is now read-only.
Bygg og deploy #27
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: Bygg og deploy | |
on: | |
workflow_dispatch: | |
inputs: | |
cluster: | |
description: 'Cluster å deploye til' | |
required: true | |
default: 'dev-gcp' | |
type: choice | |
options: | |
- 'dev-gcp' | |
- 'prod-gcp' | |
push: | |
branches: | |
- main | |
paths-ignore: | |
- '**.md' | |
- '.github/workflows/**.yml' | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
IMAGE: europe-north1-docker.pkg.dev/${{ vars.NAIS_MANAGEMENT_PROJECT_ID }}/aap/${{ github.event.repository.name }} | |
jobs: | |
bygg: | |
permissions: | |
contents: write | |
id-token: write | |
packages: write | |
runs-on: ubuntu-latest | |
outputs: | |
image: ${{ steps.docker-push.outputs.image }} | |
steps: | |
- name: Sjekker ut kode | |
uses: actions/checkout@v4.1.1 | |
- name: Setter opp Java 17 | |
uses: actions/setup-java@v3.13.0 | |
with: | |
java-version: 17 | |
distribution: temurin | |
cache: maven | |
- name: Setter tag-navn | |
run: echo "TAG=$(date +%Y.%m.%d.%H%M%S)-$(echo $GITHUB_SHA | cut -c1-7)" >> $GITHUB_ENV | |
- name: Login GAR | |
uses: nais/login@v0 | |
with: | |
project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }} | |
identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }} | |
team: aap | |
- name: Kompilerer, bygger og pusher image | |
id: kompiler | |
run: | | |
echo "image=${{ env.IMAGE }}:${{ env.TAG }}" >> $GITHUB_OUTPUT | |
./mvnw --settings .github/.m2/settings.xml -DGAR_TOKEN=${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }} -Djib.to.tags=latest,${TAG} -Drevision=${TAG} package jib:build | |
- name: Submit Dependency Snapshot | |
uses: advanced-security/maven-dependency-submission-action@v3 | |
with: | |
settings-file: .github/.m2/settings.xml | |
deploy_dev_gcp: | |
if: github.event.inputs.cluster == 'dev-gcp' || github.event_name == 'push' | |
needs: bygg | |
permissions: | |
contents: read | |
id-token: write | |
runs-on: ubuntu-latest | |
timeout-minutes: 30 | |
environment: dev-gcp:aap | |
env: | |
PRINT_PAYLOAD: true | |
RESOURCE: .nais/naiserator.yaml,.nais/dev-gcp-alerts.yaml | |
CLUSTER: dev-gcp | |
VARS: .nais/dev-gcp.json | |
VAR: image=${{ needs.build.outputs.image }} | |
steps: | |
- uses: actions/checkout@v4.1.1 | |
- uses: nais/deploy/actions/deploy@v2 | |
deploy_prod_gcp: | |
if: github.event.inputs.cluster == 'prod-gcp' | |
needs: bygg | |
permissions: | |
contents: read | |
id-token: write | |
runs-on: ubuntu-latest | |
timeout-minutes: 30 | |
environment: prod-gcp:aap | |
env: | |
PRINT_PAYLOAD: true | |
RESOURCE: .nais/naiserator.yaml,.nais/prod-gcp-alerts.yaml | |
CLUSTER: prod-gcp | |
VARS: .nais/prod-gcp.json | |
VAR: image=${{ needs.build.outputs.image }} | |
steps: | |
- uses: actions/checkout@v4.1.1 | |
- uses: nais/deploy/actions/deploy@v2 |