-
Notifications
You must be signed in to change notification settings - Fork 1
113 lines (107 loc) · 3.27 KB
/
deploy.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
name: Deploy to dev
on:
push:
branches:
- main
jobs:
build:
permissions:
contents: "write"
id-token: "write"
security-events: "write"
name: Checkout code and create docker tag
runs-on: ubuntu-latest
steps:
- name: Setup java
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'
- name: Checkout code
uses: actions/checkout@v4
- name: Gradle wrapper validation
uses: gradle/[email protected]
- name: Setup gradle dependency cache
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/.*gradle*') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Run tests
run: |
./gradlew test
- name: setup frontend
uses: actions/setup-node@v4
with:
node-version: '22'
- run: corepack enable
- run: yarn --immutable
env:
NPM_AUTH_TOKEN: ${{ secrets.READER_TOKEN }}
working-directory: web
- run: yarn build
working-directory: web
- run: yarn copy
working-directory: web
- name: Build jar
run: |
./gradlew shadowJar -x test
- name: docker-build-push
if: github.event.pull_request.user.login != 'dependabot[bot]'
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 }}
outputs:
image: ${{ steps.docker-build-push.outputs.image }}
trivy-docker:
if: github.event.pull_request.user.login != 'dependabot[bot]'
permissions:
contents: "write"
id-token: "write"
security-events: "write"
name: Trivy docker
runs-on: ubuntu-latest
needs: [ build ]
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@6c175e9c4083a92bbca2f9724c8a5e33bc2d97a5
with:
image-ref: ${{ needs.build.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'
deploy-dev:
if: github.event.pull_request.user.login != 'dependabot[bot]'
name: Deploy to dev
runs-on: ubuntu-latest
needs: [ build ]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Deploy to dev
uses: nais/deploy/actions/deploy@master
env:
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }}
CLUSTER: dev-gcp
RESOURCE: naiserator-dev.yaml
VAR: image=${{ needs.build.outputs.image }}