-
Notifications
You must be signed in to change notification settings - Fork 2
108 lines (91 loc) · 2.85 KB
/
golang-terratest.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
---
name: golang-terratest
run-name: Build golang-terratest
on:
pull_request:
paths:
- 'pipelines/dockerfiles/golang-terratest/**'
- .github/workflows/golang-terratest.yml
branches: [ master ]
push:
paths:
- 'pipelines/dockerfiles/golang-terratest/**'
- .github/workflows/golang-terratest.yml
workflow_dispatch:
defaults:
run:
shell: bash
working-directory: pipelines/dockerfiles/golang-terratest
jobs:
get-version:
runs-on: ubuntu-22.04
permissions:
contents: read
outputs:
version: ${{ steps.get-version.outputs.version }}
steps:
- name: Checkout source code
uses: actions/checkout@v4
- name: Get version
id: get-version
run: |
version="$(cat Makefile | grep TAG | head -n 1 | awk '{print $3}')"
echo "version=${version}" >> "$GITHUB_OUTPUT"
echo "::notice::Tag version: $version"
checkov:
runs-on: ubuntu-22.04
permissions:
security-events: write
steps:
- name: Checkout source code
uses: actions/checkout@v4
- name: Run Checkov action
uses: bridgecrewio/checkov-action@master
with:
directory: pipelines/dockerfiles/golang-terratest
framework: dockerfile
skip_check: CKV_DOCKER_2
output_format: sarif
output_file_path: checkov-results.sarif
soft_fail: true
- name: Upload Checkov results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: checkov-results.sarif
build:
needs: [ get-version ]
runs-on: ubuntu-22.04
permissions:
security-events: write
steps:
- name: Checkout source code
uses: actions/checkout@v4
- name: Docker login
env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
run: make login
- name: Docker build
run: make build
- name: Run trivy scan (console output)
uses: aquasecurity/[email protected]
with:
image-ref: constantin07/golang-terratest:${{ needs.get-version.outputs.version }}
ignore-unfixed: true
severity: 'LOW,MEDIUM,HIGH,CRITICAL'
format: table
- name: Run trivy scan (report upload)
uses: aquasecurity/[email protected]
with:
image-ref: constantin07/golang-terratest:${{ needs.get-version.outputs.version }}
ignore-unfixed: true
severity: 'LOW,MEDIUM,HIGH,CRITICAL'
format: sarif
output: trivy-results.sarif
- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v3
if: always()
with:
sarif_file: trivy-results.sarif
- name: Docker publish
run: make publish