-
Notifications
You must be signed in to change notification settings - Fork 1
75 lines (63 loc) · 1.97 KB
/
on-push-to-main.yaml
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
name: Bygg og publiser docker-image for main
on:
push:
branches:
- master
- main
paths-ignore:
- .github/workflows/**
- README.md
- howto.md
permissions:
contents: write
packages: write
jobs:
build:
runs-on: ubuntu-latest
outputs:
image: ${{ env.IMAGE }}
steps:
- name: Sjekk ut koden
uses: actions/checkout@v2
- name: Setup java
uses: actions/setup-java@v1
with:
java-version: '17.x'
- name: Finn cache-variabler
uses: navikt/pb-common-gh-actions/cache-prep@v2
- name: Sett opp cache
uses: actions/cache@v2
with:
path: |
${{ env.CACHE_PATHS }}
key: ${{ runner.os }}${{ env.CACHE_KEY_NAMESPACE }}${{ hashFiles(env.CACHE_KEY_HASHED_PATH) }}
- name: Bygg prosjekt og kjør tester
uses: navikt/pb-common-gh-actions/build@v2
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Bygg, tag og push Docker image
uses: navikt/pb-common-gh-actions/docker-publish@v2
with:
TAG_LATEST: "true"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
deploy:
runs-on: ubuntu-latest
needs: build
strategy:
matrix:
cluster: [dev-gcp, prod-gcp]
steps:
- name: Sjekk ut koden
uses: actions/checkout@v2
- name: 'Sjekk om deploy til ${{ matrix.cluster }} er mulig'
run: echo "DEPLOY_CONFIG_DEFINED=$([[ -f ./nais/${{ matrix.cluster }}/nais.yaml ]] && echo 'true' || echo 'false')" >> $GITHUB_ENV
- name: 'Deploy-er til ${{ matrix.cluster }}'
if: env.DEPLOY_CONFIG_DEFINED == 'true'
uses: 'nais/deploy/actions/deploy@v1'
env:
REF: ${{ github.sha }}
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }}
CLUSTER: ${{ matrix.cluster }}
RESOURCE: ./nais/${{ matrix.cluster }}/nais.yaml
VAR: version=${{ needs.build.outputs.image }}
PRINT_PAYLOAD: true