Skip to content
This repository has been archived by the owner on Jul 5, 2024. It is now read-only.

Bygg og deploy

Bygg og deploy #18

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 }}
jobs:
bygg:
permissions:
contents: write
id-token: write
runs-on: ubuntu-latest
outputs:
image: ${{ steps.docker-push.outputs.image }}
steps:
- name: Sjekker ut kode
uses: actions/[email protected]
- name: Setter opp Java 17
uses: actions/[email protected]
with:
java-version: 17
distribution: temurin
cache: maven
- name: Bygg og last opp image
uses: nais/docker-build-push@v0
id: docker-push
with:
team: aap # required
project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }} # required, but is defined as an organization variable
identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }} # required, but is defined as an organization secret
- 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
runs-on: ubuntu-latest
timeout-minutes: 30
environment: dev-gcp:aap
env:
PRINT_PAYLOAD: true
APIKEY: ${{secrets.NAIS_DEPLOY_APIKEY}}
RESOURCE: .nais/naiserator.yaml,.nais/dev-gcp-alerts.yaml
CLUSTER: dev-gcp
VARS: .nais/dev-gcp.json
IMAGE: ${{needs.bygg.outputs.image}}
steps:
- uses: actions/[email protected]
- uses: nais/deploy/actions/deploy@v1
deploy_prod_gcp:
if: github.event.inputs.cluster == 'prod-gcp'
needs: bygg
runs-on: ubuntu-latest
timeout-minutes: 30
environment: prod-gcp:aap
env:
PRINT_PAYLOAD: true
APIKEY: ${{secrets.NAIS_DEPLOY_APIKEY}}
RESOURCE: .nais/naiserator.yaml,.nais/prod-gcp-alerts.yaml
CLUSTER: prod-gcp
VARS: .nais/prod-gcp.json
IMAGE: ${{needs.bygg.outputs.image}}
steps:
- uses: actions/[email protected]
- uses: nais/deploy/actions/deploy@v1