-
Notifications
You must be signed in to change notification settings - Fork 13
114 lines (109 loc) · 3.45 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
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@v3
- uses: github/codeql-action/init@v2
- name: Autobuild
uses: github/codeql-action/autobuild@v2
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
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.0.25
- run: yarn test
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:
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
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@v3
- 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@v3
- 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 }}