-
Notifications
You must be signed in to change notification settings - Fork 0
164 lines (138 loc) · 4.45 KB
/
ci.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
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
# SPDX-License-Identifier: MIT
name: CI
on:
push:
branches:
- main
- feature/**
paths-ignore:
- '**.md'
- '.gitignore'
pull_request:
branches:
- main
env:
GORELEASER_VERSION: 2.5.0
TASK_VERSION: 3.x
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
local-build:
name: Local build
runs-on: ubuntu-24.04
permissions: {}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: './go.mod'
- name: Setup Task
uses: arduino/setup-task@v2
with:
version: ${{ env.TASK_VERSION }}
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
install-only: true
- name: Setup container-structure-test
run: |
set -euo pipefail
curl -fsSLo /usr/local/bin/container-structure-test https://storage.googleapis.com/container-structure-test/latest/container-structure-test-linux-amd64
chmod +x /usr/local/bin/container-structure-test
container-structure-test version
- name: Check release config
run: |
task goreleaser:check
- name: Build with GoReleaser
run: |
task goreleaser:build
- name: Create snapshot release
run: |
task goreleaser:snapshot
- name: Build
run: |
task build
- name: Test
run: |
task test
release-dry-run:
name: GoReleaser release (dry run)
runs-on: ubuntu-24.04
permissions:
actions: read
checks: write
contents: read
security-events: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: './go.mod'
- name: Set environment variables
run: |
set -euo pipefail
echo "SNAPSHOT_VERSION=$(./scripts/version)" >>"${GITHUB_ENV}"
IMAGE_BASE_NAME_DISTROLESS="$(sed -n "s/^FROM \(.*\)/\1/p" build/package/Dockerfile | tail -n 1)"
echo "IMAGE_BASE_NAME_DISTROLESS=${IMAGE_BASE_NAME_DISTROLESS}" >>"${GITHUB_ENV}"
echo "IMAGE_BASE_DIGEST_DISTROLESS=$(docker pull "${IMAGE_BASE_NAME_DISTROLESS}" | sed -n "s/^Digest: \(.*\)$/\1/p")" >>"${GITHUB_ENV}"
- name: Check release config
uses: goreleaser/goreleaser-action@v6
with:
version: v${{ env.GORELEASER_VERSION }}
args: check --config build/package/.goreleaser.yaml
- name: Create snapshot release
uses: goreleaser/goreleaser-action@v6
with:
version: v${{ env.GORELEASER_VERSION }}
args: release --config build/package/.goreleaser.yaml --snapshot --skip=publish --clean
- name: Container structure test (distroless)
uses: docker://gcr.io/gcp-runtimes/container-structure-test:latest
with:
args: 'test --image ghcr.io/ffurrer2/semver:latest --config test/semver_container_test.yml'
- name: Run Trivy vulnerability scanner (distroless)
uses: aquasecurity/trivy-action@master
with:
image-ref: 'ghcr.io/ffurrer2/semver:latest'
exit-code: '1'
vuln-type: 'os,library'
severity: 'HIGH,CRITICAL'
format: 'sarif'
output: 'trivy-results-distroless.sarif'
github-pat: '${{ secrets.GITHUB_TOKEN }}'
- name: Inspect Trivy SARIF report (distroless)
run: |
cat trivy-results-distroless.sarif
if: ${{ !cancelled() }}
- name: Upload Trivy scan results to GitHub Security tab (distroless)
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: 'trivy-results-distroless.sarif'
category: trivy-results-distroless
if: ${{ !cancelled() }}
- name: Run Anchore image scanner (distroless)
uses: anchore/scan-action@v6
id: anchore-distroless
with:
image: 'ghcr.io/ffurrer2/semver:latest'
fail-build: true
severity-cutoff: high
if: ${{ !cancelled() }}
- name: Inspect Anchore SARIF report (distroless)
run: |
cat ${{ steps.anchore-distroless.outputs.sarif }}
if: ${{ !cancelled() }}
- name: Upload Anchore scan results to GitHub Security tab (distroless)
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: ${{ steps.anchore-distroless.outputs.sarif }}
if: ${{ !cancelled() }}