-
Notifications
You must be signed in to change notification settings - Fork 1
150 lines (142 loc) · 4.78 KB
/
app-etterlatte-saksbehandling-ui.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: etterlatte-saksbehandling-ui
env:
APP_NAME: ${{ github.workflow }}
on:
workflow_dispatch: # Allow manually triggered workflow run
inputs:
deploy-prod:
description: 'Deploy til produksjon'
required: false
default: 'false'
type: choice
options:
- true
- false
push:
branches:
- main
paths:
- apps/etterlatte-saksbehandling-ui/**
pull_request:
branches:
- main
paths:
- apps/etterlatte-saksbehandling-ui/**
- "!apps/etterlatte-saksbehandling-ui/.nais/*"
permissions:
contents: read
id-token: write
jobs:
test:
if: github.event_name == 'pull_request'
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '20.x'
cache: 'yarn'
cache-dependency-path: apps/${{ env.APP_NAME }}/client/yarn.lock
- name: Install client
working-directory: apps/${{ env.APP_NAME }}
run: yarn --cwd client install --frozen-lockfile && yarn --cwd client build
- name: Install server
working-directory: apps/${{ env.APP_NAME }}
run: yarn --cwd server install --frozen-lockfile && yarn --cwd server build
- name: Run tests
working-directory: apps/${{ env.APP_NAME }}/client
run: CI=true yarn test
build:
if: github.event_name != 'pull_request'
name: Build, test and publish
runs-on: ubuntu-latest
outputs:
image: ${{ steps.docker-build-push.outputs.image }}
digest: ${{ steps.docker-build-push.outputs.digest }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '20.x'
cache: 'yarn'
cache-dependency-path: apps/${{ env.APP_NAME }}/client/yarn.lock
- name: Inject slug/short variables
uses: rlespinasse/github-slug-action@v5
- name: License check top level
working-directory: apps/${{ env.APP_NAME }}
run: yarn install --frozen-lockfile && yarn lisenssjekk
- name: Install and build client
working-directory: apps/${{ env.APP_NAME }}
run: yarn --cwd client install --frozen-lockfile && yarn --cwd client build
- name: Install and build server
working-directory: apps/${{ env.APP_NAME }}
run: yarn --cwd server install --frozen-lockfile && yarn --cwd server build
- name: Run tests
working-directory: apps/${{ env.APP_NAME }}/client
run: CI=true yarn test
- name: Build and publish Docker image
uses: nais/docker-build-push@v0
id: docker-build-push
with:
team: etterlatte
identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }}
project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }}
salsa: false
docker_context: apps/${{ env.APP_NAME }}/
image_suffix: ${{ github.workflow }}
tag: ${{ env.GITHUB_REF_SLUG }}
salsa:
name: Generate SBOM, attest and sign image
runs-on: ubuntu-latest
needs: build
permissions:
id-token: write
steps:
- name: NAIS login
uses: nais/login@v0
id: login
with:
identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }}
project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }}
team: etterlatte
- name: Lag image-referanse med digest
run: |
IMAGE_WITH_TAG="${{ needs.build.outputs.image }}"
IMAGE="${IMAGE_WITH_TAG%%:*}"
echo "IMAGE_WITH_DIGEST=${IMAGE}@${{ needs.build.outputs.digest }}" >> $GITHUB_ENV
- name: Generate SBOM, attest and sign image
id: attest-sign
uses: nais/attest-sign@v1
env:
TRIVY_JAVA_DB_REPOSITORY: "public.ecr.aws/aquasecurity/trivy-java-db:1"
with:
image_ref: ${{ env.IMAGE_WITH_DIGEST }}
deploy-to-dev-gcp:
if: github.event_name != 'pull_request'
name: Deploy to dev-gcp
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: nais/deploy/actions/deploy@v2
env:
CLUSTER: dev-gcp
RESOURCE: apps/${{ env.APP_NAME }}/.nais/dev.yaml
VAR: image=${{ needs.build.outputs.image }}
deploy-to-prod-gcp:
name: Deploy to prod-gcp
if: ${{ github.ref == 'refs/heads/main' || github.event.inputs.deploy-prod == 'true' }}
needs: [build,deploy-to-dev-gcp]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: nais/deploy/actions/deploy@v2
env:
CLUSTER: prod-gcp
RESOURCE: apps/${{ env.APP_NAME }}/.nais/prod.yaml
VAR: image=${{ needs.build.outputs.image }}