forked from navikt/helsesjekk-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
168 lines (159 loc) · 5.07 KB
/
deploy.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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
name: Build and deploy
on: push
jobs:
codeql-analysis:
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
permissions:
security-events: write
steps:
- uses: actions/checkout@v4
- uses: github/codeql-action/init@v3
- name: Autobuild
uses: github/codeql-action/autobuild@v3
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
test:
name: 'Run bun tests'
runs-on: ubuntu-latest
steps:
- uses: navikt/teamsykmelding-github-actions-workflows/actions/yarn-cached@main
with:
NPM_AUTH_TOKEN: ${{ secrets.READER_TOKEN }}
- uses: oven-sh/setup-bun@v1
with:
bun-version: 1.1.22
#- run: yarn test
- run: echo "Tests are skipped!"
build-and-publish:
if: github.ref == 'refs/heads/main'
name: 'Prod: Bygg, test og push Docker image'
runs-on: ubuntu-latest
permissions:
packages: 'write'
contents: 'read'
id-token: 'write'
outputs:
image: ${{ steps.docker-build-push.outputs.image }}
steps:
- uses: navikt/teamsykmelding-github-actions-workflows/actions/yarn-cached@main
with:
NPM_AUTH_TOKEN: ${{ secrets.READER_TOKEN }}
- run: yarn lint
- run: yarn build
env:
NEXT_PUBLIC_ENVIRONMENT: production
- name: Push docker image to GAR
uses: nais/docker-build-push@v0
id: docker-build-push
with:
team: teamsykmelding
identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }}
project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }}
image_suffix: prod
build-and-publish-dev:
if: github.actor != 'dependabot[bot]'
name: 'Dev: Bygg, test og push Docker image'
runs-on: ubuntu-latest
permissions:
packages: 'write'
contents: 'read'
id-token: 'write'
outputs:
image: ${{ steps.docker-build-push.outputs.image }}
steps:
- uses: navikt/teamsykmelding-github-actions-workflows/actions/yarn-cached@main
with:
NPM_AUTH_TOKEN: ${{ secrets.READER_TOKEN }}
- run: yarn lint
- run: yarn build
env:
NEXT_PUBLIC_ENVIRONMENT: dev
- name: Push docker image to GAR
uses: nais/docker-build-push@v0
id: docker-build-push
with:
team: teamsykmelding
identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }}
project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }}
image_suffix: dev
build-for-dependabot:
if: github.actor == 'dependabot[bot]'
name: 'Build for dependabot'
runs-on: ubuntu-latest
permissions:
packages: 'write'
contents: 'read'
id-token: 'write'
outputs:
image: ${{ steps.docker-build-push.outputs.image }}
steps:
- uses: navikt/teamsykmelding-github-actions-workflows/actions/yarn-cached@main
with:
NPM_AUTH_TOKEN: ${{ secrets.READER_TOKEN }}
- run: yarn lint
- run: yarn build
env:
NEXT_PUBLIC_ENVIRONMENT: dev
deploy-bot-to-gcp:
if: github.ref == 'refs/heads/main'
name: Deploy to prod
needs: [build-and-publish, codeql-analysis, test]
runs-on: ubuntu-latest
environment:
name: production
url: https://helsesjekk-bot.nav.no
steps:
- uses: actions/checkout@v4
- uses: nais/deploy/actions/deploy@v1
env:
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }}
CLUSTER: prod-gcp
RESOURCE: nais.yml
VAR: image=${{ needs.build-and-publish.outputs.image }}
deploy-bot-to-gcp-dev:
if: github.ref != 'refs/heads/main'
name: Deploy to dev
needs: [build-and-publish-dev, test]
runs-on: ubuntu-latest
environment:
name: development
url: https://helsesjekk-bot.intern.dev.nav.no
steps:
- uses: actions/checkout@v4
- uses: nais/deploy/actions/deploy@v1
env:
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }}
CLUSTER: dev-gcp
RESOURCE: nais-dev.yml
VAR: image=${{ needs.build-and-publish-dev.outputs.image }}
trivy-docker:
permissions:
contents: 'write'
id-token: 'write'
security-events: 'write'
name: Trivy docker
runs-on: ubuntu-latest
needs: [build-and-publish]
steps:
- run: touch me
- uses: nais/login@v0
with:
project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }}
identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }}
team: teamsykmelding
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@d710430a6722f083d3b36b8339ff66b32f22ee55
with:
image-ref: ${{ needs.build-and-publish.outputs.image }}
ignore-unfixed: true
vuln-type: 'os'
severity: 'CRITICAL,HIGH'
format: 'sarif'
output: 'trivy-results.sarif'
scanners: 'vuln'
- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v3
if: always()
with:
sarif_file: 'trivy-results.sarif'