This repository has been archived by the owner on Jul 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
95 lines (86 loc) · 3.21 KB
/
build-and-deploy.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
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/[email protected]
- name: Setter opp Java 17
uses: actions/[email protected]
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
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
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
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