-
Notifications
You must be signed in to change notification settings - Fork 1
156 lines (138 loc) · 4.39 KB
/
cicd.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
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
151
152
153
154
155
156
name: Test, bygg, deploy
on:
push:
workflow_dispatch:
schedule:
- cron: '0 6 * * 1' # bygg nytt image hver mandag morgen
jobs:
build:
name: Bygg
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
packages: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '22'
registry-url: https://npm.pkg.github.com/
cache: 'npm'
- run: npm ci --omit=dev --omit=optional
env:
NODE_AUTH_TOKEN: ${{ secrets.READER_TOKEN }}
working-directory: ./server
- run: npm ci
env:
NODE_AUTH_TOKEN: ${{ secrets.READER_TOKEN }}
- run: npm run test
- run: npm run lint
- run: npm run build
- run: npx @cyclonedx/cyclonedx-npm --package-lock-only --ignore-npm-errors --output-file sbom1.json
- run: npx @cyclonedx/cyclonedx-npm --package-lock-only --omit dev --ignore-npm-errors --output-file sbom2.json server/package.json
- run: jq -s '.[0] * .[1]' sbom1.json sbom2.json > sbom.merged.json
- uses: actions/upload-artifact@v4
with:
name: ${{ github.sha }}.bom.json
path: sbom.merged.json
- uses: nais/docker-build-push@v0
id: gar-push
with:
team: fager
salsa: false
tag: ${{ github.sha }}
project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }}
identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }}
- id: upload
uses: nais/deploy/actions/cdn-upload/v2@master
with:
team: fager
source: ./build/
destination: '/min-side-arbeidsgiver'
identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }}
project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }}
outputs:
image: ${{ steps.gar-push.outputs.image }}
digest: ${{ steps.gar-push.outputs.digest }}
salsa:
name: attest and sign image
needs: [ build ]
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- uses: nais/login@v0
id: login
with:
project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }}
identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }}
team: fager
- uses: actions/download-artifact@v4
with:
name: ${{ github.sha }}.bom.json
path: ./
- uses: nais/attest-sign@v1
with:
image_ref: ${{ needs.build.outputs.image }}@${{ needs.build.outputs.digest }}
sbom: sbom.merged.json
deploy-dev-gcp:
needs: [ build ]
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
permissions:
id-token: write
steps:
- uses: actions/checkout@v4
- name: Deploy til dev-gcp
uses: nais/deploy/actions/deploy@v2
env:
CLUSTER: dev-gcp
RESOURCE: nais/dev-gcp.yaml
PRINT_PAYLOAD: true
VAR: commit=${{ github.sha }},image=${{ needs.build.outputs.image }}
deploy-prod-gcp:
needs: [ build ]
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
permissions:
id-token: write
steps:
- uses: actions/checkout@v4
- name: Deploy til prod-gcp
uses: nais/deploy/actions/deploy@v2
env:
CLUSTER: prod-gcp
RESOURCE: nais/prod-gcp.yaml
PRINT_PAYLOAD: true
VAR: commit=${{ github.sha }},image=${{ needs.build.outputs.image }}
deploy-prodlik-demo-gcp:
needs: [ build ]
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
permissions:
id-token: write
steps:
- uses: actions/checkout@v4
- name: Deploy prodlik demo til dev-gcp
uses: nais/deploy/actions/deploy@v2
env:
CLUSTER: dev-gcp
RESOURCE: nais/demo-prodlik.yaml
PRINT_PAYLOAD: true
VAR: commit=${{ github.sha }},image=${{ needs.build.outputs.image }}
deploy-devlik-demo-gcp:
needs: [ build ]
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
permissions:
id-token: write
steps:
- uses: actions/checkout@v4
- name: Deploy dev-lik demo til dev-gcp
uses: nais/deploy/actions/deploy@v2
env:
CLUSTER: dev-gcp
RESOURCE: nais/demo-devlik.yaml
PRINT_PAYLOAD: true
VAR: commit=${{ github.sha }},image=${{ needs.build.outputs.image }}