-
Notifications
You must be signed in to change notification settings - Fork 0
150 lines (139 loc) · 5.14 KB
/
deploy-fyllut.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
name: "Deploy 'fyllut'"
on:
push:
branches:
- master
- dev-deploy
env:
IMAGE_FYLLUT_BASE: "europe-north1-docker.pkg.dev/nais-management-233d/skjemadigitalisering/skjemabygging-formio-${{ github.ref == 'refs/heads/master' && 'fyllut-base' || 'fyllut-base-dev' }}"
MONOREPO_BASE_URL: "https://raw.githubusercontent.com/navikt/skjemabygging-formio"
PUSHER_APP_SECRET: ${{ secrets.PUSHER_APP_SECRET }}
BYGGER_URL: "https://skjemabygging.nav.no"
concurrency: deploy-${{ github.ref }}
jobs:
package-and-push-fyllut:
name: "Package 'fyllut'"
runs-on: ubuntu-latest
permissions:
contents: "read"
id-token: "write"
packages: "read"
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "lts/*"
- name: Read monorepo commit sha
run: echo "MONOREPO_GIT_SHA=$(cat MONOREPO)" >> $GITHUB_ENV
- name: "Build and push Docker image"
uses: nais/docker-build-push@v0
id: docker-build-push
with:
team: skjemadigitalisering
identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }}
project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }}
image_suffix: ${{ github.ref == 'refs/heads/master' && 'fyllut' || 'fyllut-dev' }}
build_args: |
git_sha=${{ github.sha }}
monorepo_git_sha=${{ env.MONOREPO_GIT_SHA }}
skjema_dir=forms
translation_dir=translations
resources_dir=resources
image_fyllut_base=${{ env.IMAGE_FYLLUT_BASE }}
pull: true
- name: "Notify job failure"
if: ${{ github.ref == 'refs/heads/master' && failure() }}
run: yarn && cat $GITHUB_EVENT_PATH | node bin/notifyDeploy.mjs failure
outputs:
image: ${{ steps.docker-build-push.outputs.image }}
deploy-fyllut-to-prod:
name: "Deploy 'fyllut' to prod"
if: github.ref == 'refs/heads/master'
needs: "package-and-push-fyllut"
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "lts/*"
- name: Fetch NAIS config
run: bin/fetchNaisConfig.sh prod fyllut-config
- name: "Deploy to prod"
uses: "nais/deploy/actions/deploy@v2"
env:
CLUSTER: "prod-gcp"
RESOURCE: "./fyllut-config/config.yaml"
VARS: "./fyllut-config/prod.yaml"
VAR: "image=${{ needs.package-and-push-fyllut.outputs.image }}"
- name: "Notify job success"
if: ${{ success() }}
run: yarn && cat $GITHUB_EVENT_PATH | node bin/notifyDeploy.mjs success
- name: "Notify job failure"
if: ${{ failure() }}
run: yarn && cat $GITHUB_EVENT_PATH | node bin/notifyDeploy.mjs failure
notify-prod-deployment-failure:
name: "Notify prod deployment failure"
if: failure() && github.ref == 'refs/heads/master'
needs: deploy-fyllut-to-prod
runs-on: ubuntu-latest
steps:
- name: "Slack notification"
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_FOOTER: "Deploy av fyllut til prod har feilet."
SLACK_COLOR: failure
deploy-fyllut-to-dev:
name: "Deploy 'fyllut' to dev"
if: github.ref == 'refs/heads/dev-deploy'
needs: "package-and-push-fyllut"
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Fetch NAIS config
run: bin/fetchNaisConfig.sh dev fyllut-config
- name: "Deploy to dev"
uses: "nais/deploy/actions/deploy@v2"
env:
CLUSTER: "dev-gcp"
RESOURCE: "./fyllut-config/config.yaml"
VARS: "./fyllut-config/dev.yaml"
VAR: "image=${{ needs.package-and-push-fyllut.outputs.image }}"
deploy-fyllut-delingslenke-to-dev:
name: "Deploy 'fyllut'-delingslenke to dev"
if: github.ref == 'refs/heads/dev-deploy'
needs: "package-and-push-fyllut"
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Fetch NAIS config
run: bin/fetchNaisConfig.sh dev-delingslenke fyllut-config
- name: "Deploy to dev"
uses: "nais/deploy/actions/deploy@v2"
env:
CLUSTER: "dev-gcp"
RESOURCE: "./fyllut-config/config.yaml"
VARS: "./fyllut-config/dev-delingslenke.yaml"
VAR: "image=${{ needs.package-and-push-fyllut.outputs.image }}"
notify-dev-deployment-failure:
name: "Notify dev deployment failure"
if: failure() && (github.ref == 'refs/heads/dev-deploy')
needs: [deploy-fyllut-to-dev, deploy-fyllut-delingslenke-to-dev]
runs-on: ubuntu-latest
steps:
- name: "Slack notification"
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_DEV }}
SLACK_FOOTER: "Deploy av fyllut til dev har feilet. Undersøk om det kan påvirke neste publisering fra byggeren."
SLACK_COLOR: "#ff9100"