Skip to content

Commit 6963017

Browse files
committed
Updated workflow files to current templig state.
Signed-off-by: Alexander Adam <alphaone23@gmail.com>
1 parent bafeb75 commit 6963017

8 files changed

Lines changed: 125 additions & 172 deletions

File tree

.github/workflows/compliance.yml

Lines changed: 105 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -19,31 +19,12 @@ permissions:
1919
contents: read
2020

2121
jobs:
22-
REUSE:
23-
runs-on: ubuntu-latest
24-
steps:
25-
- name: Harden Runner
26-
uses: step-security/harden-runner@a5ad31d6a139d249332a2605b85202e8c0b78450 # v2.19.1
27-
with:
28-
egress-policy: audit
29-
30-
- name: Checkout
31-
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
32-
with:
33-
fetch-depth: 1
34-
35-
- name: REUSE Compliance Check
36-
uses: fsfe/reuse-action@676e2d560c9a403aa252096d99fcab3e1132b0f5 #v6.0.0
37-
38-
CheckSignedOffCommit:
39-
if: >
40-
github.event_name == 'push' &&
41-
!contains(github.actor, '[bot]') &&
42-
!contains(github.event.pusher.name, '[bot]') &&
43-
github.event.pusher.name != 'web-flow'
22+
CheckSignedOff:
23+
if: github.event_name != 'pull_request' || !contains(github.event.pull_request.labels.*.name, 'bypass-dco')
4424
runs-on: ubuntu-latest
4525
permissions:
4626
contents: read
27+
pull-requests: read
4728
steps:
4829
- name: Harden Runner
4930
uses: step-security/harden-runner@a5ad31d6a139d249332a2605b85202e8c0b78450 # v2.19.1
@@ -56,7 +37,11 @@ jobs:
5637
fetch-depth: 0
5738

5839
- name: Determine pushed commits
59-
id: range
40+
if: >
41+
github.event_name == 'push' &&
42+
!contains(github.actor, '[bot]') &&
43+
!contains(github.event.pusher.name, '[bot]') &&
44+
github.event.pusher.name != 'web-flow'
6045
env:
6146
# Use GitHub-provided SHAs to build the range for this push
6247
BEFORE: ${{ github.event.before }}
@@ -72,10 +57,25 @@ jobs:
7257
git rev-list --no-merges "$BEFORE".."$AFTER" > shas.txt
7358
fi
7459
60+
- name: Get PR commits
61+
if: github.event_name == 'pull_request'
62+
env:
63+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
64+
run: |
65+
set -euo pipefail
66+
67+
# Fetch all commits of the PR with pagination and extract SHAs
68+
gh api -H "Accept: application/vnd.github+json" --paginate \
69+
repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/commits \
70+
| jq -r '.[].sha' > shas.txt
71+
7572
- name: Check for Signed-off-by
7673
env:
7774
GH_ACTOR: ${{ github.actor }}
78-
GH_NAME: ${{ github.event.pusher.name }}
75+
GH_NAME: ${{ github.event.name == 'push' && github.event.pusher.name
76+
|| github.event.pull_request.user.login }}
77+
GH_NAME_SOURCE: ${{ github.event_name == 'push' && 'github.event.pusher.name'
78+
|| 'github.event.pull_request.user.login' }}
7979
run: |
8080
set -euo pipefail
8181
missing=""
@@ -102,27 +102,51 @@ jobs:
102102
echo "Commit $sha missing Signed-off-by"
103103
missing="true"
104104
105-
echo "Committer name: $committer_name"
106-
echo "Committer email: $committer_email"
107-
echo "github.actor: $GH_ACTOR"
108-
echo "github.event.pusher.name: $GH_NAME"
105+
printf "%-38s %s" "Committer name:" "$committer_name"
106+
printf "%-38s %s" "Committer email:" "$committer_email"
107+
printf "%-38s %s" "github.actor:" "$GH_ACTOR"
108+
printf "%-38s %s" "$GH_NAME_SOURCE:" "$GH_NAME"
109109
fi
110110
done < shas.txt
111111
112112
if [ "$missing" = "true" ]
113113
then
114-
echo "DCO check failed on push"
114+
echo "DCO check failed for commits"
115115
exit 1
116116
fi
117117
118-
echo "All pushed commits are signed"
118+
echo "All commits are signed"
119+
120+
FormatCheck:
121+
strategy:
122+
matrix:
123+
go-version:
124+
- "stable"
125+
runs-on: ubuntu-latest
126+
steps:
127+
- name: Harden Runner
128+
uses: step-security/harden-runner@a5ad31d6a139d249332a2605b85202e8c0b78450 # v2.19.1
129+
with:
130+
egress-policy: audit
131+
132+
- name: Install Go
133+
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
134+
with:
135+
go-version: ${{matrix.go-version}}
136+
137+
- name: Checkout
138+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
139+
with:
140+
fetch-depth: 1
141+
142+
- name: FormatCheck
143+
run: if [ `go fmt ./... | wc -l` -gt 0 ] ; then echo "Found unformatted code" ; exit 1 ; else exit 0 ; fi
119144

120-
CheckSignedOffPullRequest:
121-
if: github.event_name == 'pull_request' && !contains(github.event.pull_request.labels.*.name, 'bypass-dco')
145+
GolangCI:
122146
runs-on: ubuntu-latest
123147
permissions:
124148
contents: read
125-
pull-requests: read
149+
security-events: write
126150
steps:
127151
- name: Harden Runner
128152
uses: step-security/harden-runner@a5ad31d6a139d249332a2605b85202e8c0b78450 # v2.19.1
@@ -132,61 +156,61 @@ jobs:
132156
- name: Checkout
133157
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
134158
with:
135-
fetch-depth: 0
159+
fetch-depth: 1
136160

137-
- name: Get PR commits
138-
env:
139-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
140-
run: |
141-
set -euo pipefail
142-
gh --version
143-
jq --version
161+
- name: Run golangci-lint
162+
uses: golangci/golangci-lint-action@1e7e51e771db61008b38414a730f564565cf7c20 # v9.2.0
163+
with:
164+
version: latest
165+
args: --timeout=5m --output.sarif.path=golangci-lint-results.sarif --output.text.path=stdout
144166

145-
# Fetch all commits of the PR with pagination and extract SHAs
146-
gh api -H "Accept: application/vnd.github+json" --paginate \
147-
repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/commits \
148-
| jq -r '.[].sha' > shas.txt
167+
- name: Upload golangci-lint results to GitHub Security tab
168+
uses: github/codeql-action/upload-sarif@95e58e9a2cdfd71adc6e0353d5c52f41a045d225 # v4.35.2
169+
with:
170+
sarif_file: golangci-lint-results.sarif
149171

150-
- name: Check for Signed-off-by
151-
env:
152-
GH_ACTOR: ${{ github.actor }}
153-
GH_NAME: ${{ github.event.pull_request.user.login}}
154-
run: |
155-
set -euo pipefail
156-
missing=""
172+
REUSE:
173+
runs-on: ubuntu-latest
174+
steps:
175+
- name: Harden Runner
176+
uses: step-security/harden-runner@a5ad31d6a139d249332a2605b85202e8c0b78450 # v2.19.1
177+
with:
178+
egress-policy: audit
157179

158-
while read -r sha
159-
do
160-
[ -n "$sha" ] || continue
180+
- name: Checkout
181+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
182+
with:
183+
fetch-depth: 1
161184

162-
# Skip commits from bots
163-
committer_name=`git log --format=%cn -n 1 "$sha"`
164-
committer_email=`git log --format=%ce -n 1 "$sha"`
165-
if echo "$committer_name" | grep -Fq '[bot]' \
166-
|| [ "$committer_name" = "web-flow" ] \
167-
|| echo "$committer_email" | grep -Eqi 'noreply@github\.com$|@users\.noreply\.github\.com$'
168-
then
169-
echo "Skipping commit $sha from $committer_name <$committer_email>"
170-
continue
171-
fi
185+
- name: REUSE Compliance Check
186+
uses: fsfe/reuse-action@676e2d560c9a403aa252096d99fcab3e1132b0f5 #v6.0.0
172187

173-
msg=`git log --format=%B -n 1 "$sha"`
188+
StaticCheck:
189+
strategy:
190+
matrix:
191+
go-version:
192+
- "stable"
193+
runs-on: ubuntu-latest
194+
steps:
195+
- name: Harden Runner
196+
uses: step-security/harden-runner@a5ad31d6a139d249332a2605b85202e8c0b78450 # v2.19.1
197+
with:
198+
egress-policy: audit
174199

175-
if ! printf '%s' "$msg" | grep -Eqi '^[[:space:]]*Signed[- ]off[- ]by:'
176-
then
177-
echo "Commit $sha missing Signed-off-by"
178-
missing="true"
200+
- name: Install Go
201+
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
202+
with:
203+
go-version: ${{matrix.go-version}}
179204

180-
echo "Committer name: $committer_name"
181-
echo "Committer email: $committer_email"
182-
echo "github.actor: $GH_ACTOR"
183-
echo "github.event.pull_request.user.login: $GH_NAME"
184-
fi
185-
done < shas.txt
205+
- name: Checkout
206+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
207+
with:
208+
fetch-depth: 1
186209

187-
if [ "$missing" = "true" ]
188-
then
189-
echo "DCO check failed"; exit 1
190-
fi
210+
- name: StaticCheck
211+
uses: dominikh/staticcheck-action@9716614d4101e79b4340dd97b10e54d68234e431 # v1.4.1
212+
with:
213+
version: latest
214+
install-go: false
215+
cache-key: ${{matrix.go-version}}
191216

192-
echo "All commits are signed"

.github/workflows/scorecard.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ on:
1515
schedule:
1616
- cron: '36 3 * * 2'
1717
push:
18-
branches: [ "master" ]
18+
branches:
19+
- "master"
1920

2021
# Declare default permissions as read-only.
2122
permissions: read-all

.github/workflows/security.yml

Lines changed: 8 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -15,37 +15,10 @@ on:
1515
permissions: read-all
1616

1717
jobs:
18-
GolangCI:
19-
runs-on: ubuntu-latest
20-
permissions:
21-
contents: read
22-
security-events: write
23-
steps:
24-
- name: Harden Runner
25-
uses: step-security/harden-runner@a5ad31d6a139d249332a2605b85202e8c0b78450 # v2.19.1
26-
with:
27-
egress-policy: audit
28-
29-
- name: Checkout
30-
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
31-
with:
32-
fetch-depth: 1
33-
34-
- name: Run golangci-lint
35-
uses: golangci/golangci-lint-action@1e7e51e771db61008b38414a730f564565cf7c20 # v9.2.0
36-
with:
37-
version: latest
38-
args: --timeout=5m --output.sarif.path=golangci-lint-results.sarif --output.text.path=stdout
39-
40-
- name: Upload golangci-lint results to GitHub Security tab
41-
uses: github/codeql-action/upload-sarif@95e58e9a2cdfd71adc6e0353d5c52f41a045d225 # v4.35.2
42-
with:
43-
sarif_file: golangci-lint-results.sarif
44-
4518
TrivyCode:
4619
runs-on: ubuntu-latest
4720
permissions:
48-
contents: read
21+
contents: read
4922
security-events: write
5023
steps:
5124
- name: Harden Runner
@@ -59,11 +32,11 @@ jobs:
5932
- name: Run Trivy vulnerability scanner in fs mode
6033
uses: aquasecurity/trivy-action@ed142fd0673e97e23eac54620cfb913e5ce36c25 # 0.36.0
6134
with:
62-
scan-type: 'fs'
35+
scan-type: 'fs'
6336
ignore-unfixed: true
64-
format: 'sarif'
65-
output: 'trivy-results.sarif'
66-
severity: 'CRITICAL,HIGH'
37+
format: 'sarif'
38+
output: 'trivy-results.sarif'
39+
severity: 'CRITICAL,HIGH'
6740

6841
- name: Upload Trivy scan results to GitHub Security tab
6942
uses: github/codeql-action/upload-sarif@95e58e9a2cdfd71adc6e0353d5c52f41a045d225 # v4.35.2
@@ -77,7 +50,7 @@ jobs:
7750
- "stable"
7851
runs-on: ubuntu-latest
7952
permissions:
80-
contents: read
53+
contents: read
8154
security-events: write
8255
steps:
8356
- name: Harden Runner
@@ -89,8 +62,8 @@ jobs:
8962
uses: golang/govulncheck-action@b625fbe08f3bccbe446d94fbf87fcc875a4f50ee # v1.0.4
9063
with:
9164
go-version-input: ${{matrix.go-version}}
92-
output-format: sarif
93-
output-file: govulncheck-results.sarif
65+
output-format: sarif
66+
output-file: govulncheck-results.sarif
9467

9568
- name: Print Sarif
9669
id: printSarif

.github/workflows/test.yml

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -15,60 +15,6 @@ on:
1515
permissions: read-all
1616

1717
jobs:
18-
FormatCheck:
19-
strategy:
20-
matrix:
21-
go-version:
22-
- "stable"
23-
runs-on: ubuntu-latest
24-
steps:
25-
- name: Harden Runner
26-
uses: step-security/harden-runner@a5ad31d6a139d249332a2605b85202e8c0b78450 # v2.19.1
27-
with:
28-
egress-policy: audit
29-
30-
- name: Install Go
31-
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
32-
with:
33-
go-version: ${{matrix.go-version}}
34-
35-
- name: Checkout
36-
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
37-
with:
38-
fetch-depth: 1
39-
40-
- name: FormatCheck
41-
run: if [ `go fmt ./... | wc -l` -gt 0 ] ; then echo "Found unformatted code" ; exit 1 ; else exit 0 ; fi
42-
43-
StaticCheck:
44-
strategy:
45-
matrix:
46-
go-version:
47-
- "stable"
48-
runs-on: ubuntu-latest
49-
steps:
50-
- name: Harden Runner
51-
uses: step-security/harden-runner@a5ad31d6a139d249332a2605b85202e8c0b78450 # v2.19.1
52-
with:
53-
egress-policy: audit
54-
55-
- name: Install Go
56-
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
57-
with:
58-
go-version: ${{matrix.go-version}}
59-
60-
- name: Checkout
61-
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
62-
with:
63-
fetch-depth: 1
64-
65-
- name: StaticCheck
66-
uses: dominikh/staticcheck-action@9716614d4101e79b4340dd97b10e54d68234e431 # v1.4.1
67-
with:
68-
version: latest
69-
install-go: false
70-
cache-key: ${{matrix.go-version}}
71-
7218
Test:
7319
strategy:
7420
matrix:

.golangci.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ linters:
1515

1616
disable:
1717
- exhaustruct
18+
- gomodguard
1819
- noinlineerr
1920
- nonamedreturns
2021
- wsl

0 commit comments

Comments
 (0)