-
Notifications
You must be signed in to change notification settings - Fork 0
97 lines (79 loc) · 2.36 KB
/
main.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
name: Test Gradle project
on: [push, pull_request]
jobs:
scan:
name: Gitleaks scan
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: gitleaks/gitleaks-action@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
lint-gradle-project:
runs-on: ubuntu-latest
name: Lint
steps:
- name: Checkout project source
uses: actions/checkout@v4
- name: Set Java
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
- name: Set up Gradle
uses: gradle/actions/setup-gradle@v3
- name: Run lint
run: ./gradlew lint
build-and-tests-api:
runs-on: ubuntu-latest
name: Build and test
needs: lint-gradle-project
steps:
- name: Checkout project source
uses: actions/checkout@v4
- name: Set Java
uses: actions/setup-java@v4
with:
java-version: 17
distribution: 'adopt'
- name: Set up Gradle
uses: gradle/actions/setup-gradle@v3
- name: Run build without tests
run: ./gradlew assemble
- name: Grant execute permission
run: chmod +x gradlew
- name: Run tests
run: ./gradlew test -Dspring.profiles.active=test
build-docker:
runs-on: ubuntu-latest
name: Build Docker image and scan for vulnerabilities
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKER_USER }}
password: ${{ secrets.DOCKER_SECRET }}
- name: Build
uses: docker/build-push-action@v5
with:
push: flase
tags: ${{ vars.DOCKER_IMAGE_NAME }}:latest
- name: Download Trivy
run: curl https://raw.githubusercontent.com/aquasecurity/trivy/7735ec432a83d5446d13a593ab3b27dd02649ca1/contrib/markdown.tpl -o markdown.tpl
- name: Run Trivy vulnerability scanner
uses: aquasecurity/[email protected]
with:
image-ref: ${{ vars.DOCKER_IMAGE_NAME }}:latest
format: 'template'
template: '@markdown.tpl'
output: trivy.md
exit-code: '1'
ignore-unfixed: true
vuln-type: 'os,library'
severity: 'CRITICAL,HIGH'
- run: cat trivy.md >> $GITHUB_STEP_SUMMARY
if: always()