-
Notifications
You must be signed in to change notification settings - Fork 1
86 lines (77 loc) · 2.24 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
name: Build and deploy
on:
push:
branches:
- 'master'
workflow_dispatch:
inputs:
environment:
description: 'Miljø'
required: true
default: 'q2'
type: choice
options:
- q1
- q2
- p
env:
ENVIRONMENT: ${{ github.event.inputs.environment }}
jobs:
build:
name: Build and publish Docker image
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
- name: Setup Gradle
uses: gradle/gradle-build-action@v3
- name: Build application
run: ./gradlew build
- name: Build and publish Docker image
uses: nais/docker-build-push@v0
id: docker-build-push
with:
team: meldekort
identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }}
project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }}
outputs:
image: ${{ steps.docker-build-push.outputs.image }}
deploy-dev:
if: github.event.inputs.environment != 'p'
name: Deploy to dev
needs: [ build ]
runs-on: ubuntu-latest
steps:
- name: Set default environment for push to main
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
run: echo 'ENVIRONMENT=q2' >> $GITHUB_ENV
- uses: actions/checkout@v4
- uses: nais/deploy/actions/deploy@v2
env:
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }}
CLUSTER: dev-fss
RESOURCE: .nais/nais.yaml
VAR: image=${{ needs.build.outputs.image }}
VARS: .nais/vars-${{ env.ENVIRONMENT }}.yaml
deploy-prod:
if: github.event.inputs.environment == 'p'
name: Deploy to prod
needs: [ build ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: nais/deploy/actions/deploy@v2
env:
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }}
CLUSTER: prod-fss
RESOURCE: .nais/nais.yaml
VAR: image=${{ needs.build.outputs.image }}
VARS: .nais/vars-${{ env.ENVIRONMENT }}.yaml