-
Notifications
You must be signed in to change notification settings - Fork 140
403 lines (355 loc) · 13.6 KB
/
default.yaml
File metadata and controls
403 lines (355 loc) · 13.6 KB
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
name: Main and Pull Request Pipeline
on:
push:
branches: [main]
tags:
- "v*.*.*"
pull_request:
paths-ignore:
- "*.md"
- "assets/**"
workflow_dispatch: # Allow manual trigger on existing releases
inputs:
tag:
description: 'Tag to build (e.g., v1.0.0)'
required: true
permissions:
contents: write
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Dagger Version
id: dagger_version
uses: sagikazarmark/dagger-version-action@v0.0.1
- name: Generate Document
uses: dagger/dagger-for-github@v7
with:
version: ${{ steps.dagger_version.outputs.version }}
verb: call
args: run-doc --source=. export --path=doc
- name: Check for changes
run: |
# Check if any docs have been modified
changed_files=$(git ls-files --others --modified --deleted --exclude-standard)
# If there are files changed, fail the workflow
if [ -n "$changed_files" ]; then
echo "file changes found"
echo "please check if docs were added for new commands or updated for new commands"
echo "$changed_files"
exit 1 # This will fail the workflow
else
echo "No file changes found."
fi
continue-on-error: false
- name: Run Dagger golangci-lint
uses: dagger/dagger-for-github@v7
with:
version: ${{ steps.dagger_version.outputs.version }}
verb: call
args: lint-report --source=. export --path=golangci-lint.report
- name: Generate lint summary
run: |
echo "<h2> 📝 Lint results</h2>" >> $GITHUB_STEP_SUMMARY
cat golangci-lint.report >> $GITHUB_STEP_SUMMARY
# Check if the lint report contains any content (error or issues)
if [ -s golangci-lint.report ]; then
# If the file contains content, output an error message and exit with code 1
echo "⚠️ Linting issues found!" >> $GITHUB_STEP_SUMMARY
exit 1
fi
vulnerability-check:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Dagger Version
id: dagger_version
uses: sagikazarmark/dagger-version-action@v0.0.1
- name: Run Vulnerability Check
uses: dagger/dagger-for-github@v7
with:
version: ${{ steps.dagger_version.outputs.version }}
verb: call
args: vulnerability-check-report --source=. export --path=vulnerability-check.report
- name: Generate vulnerability summary
run: |
echo "<h2> 🔒 Vulnerability Check Results</h2>" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
if grep -q "No vulnerabilities found." vulnerability-check.report; then
echo "✅ No vulnerabilities found." >> $GITHUB_STEP_SUMMARY
else
vuln_count=$(grep -c "^Vulnerability #" vulnerability-check.report || echo "0")
echo "⚠️ **Vulnerabilities detected:** $vuln_count found" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
# Table header
echo "| Vulnerability ID | Package | Found In | Fixed In | Description | Example Trace | Details |" >> $GITHUB_STEP_SUMMARY
echo "| :--- | :--- | :--- | :--- | :--- | :--- | :--- |" >> $GITHUB_STEP_SUMMARY
# Parse and format each vulnerability as a table row
awk '
BEGIN { in_vuln = 0; in_trace = 0; desc = ""; trace = "" }
/^Vulnerability #[0-9]+:/ {
if (in_vuln) {
# Print previous vulnerability as table row
gsub(/\|/, "\\|", desc)
gsub(/\|/, "\\|", trace)
if (trace == "") trace = "N/A"
print "| " vuln_id " | " pkg " | " found_ver " | " fixed_ver " | " desc " | `" trace "` | [View](https://pkg.go.dev/vuln/" vuln_id ") |"
}
vuln_id = $NF
in_vuln = 1
in_trace = 0
desc = ""
trace = ""
pkg = ""
found_ver = ""
fixed_ver = ""
next
}
in_vuln && /^[[:space:]]*Found in:/ {
found_in = $NF
split(found_in, arr, "@")
pkg = arr[1]
found_ver = arr[2]
next
}
in_vuln && /^[[:space:]]*Fixed in:/ {
fixed_in = $NF
split(fixed_in, arr, "@")
fixed_ver = arr[2]
next
}
in_vuln && /Example traces found:/ {
in_trace = 1
next
}
in_vuln && in_trace && /^[[:space:]]*#[0-9]+:/ {
sub(/^[[:space:]]*#[0-9]+:[[:space:]]*/, "")
trace = $0
next
}
in_vuln && /^More info:/ { next }
in_vuln && /^Standard library/ { next }
in_vuln && /^[[:space:]]*Module:/ { next }
in_vuln && /^Your code is affected by/ { next }
in_vuln && !in_trace && !/^[[:space:]]*$/ && !/^[[:space:]]*Found in:/ && !/^[[:space:]]*Fixed in:/ && !/^Vulnerability/ {
if (desc == "") {
desc = $0
} else {
desc = desc " " $0
}
}
END {
if (in_vuln) {
gsub(/\|/, "\\|", desc)
gsub(/\|/, "\\|", trace)
if (trace == "") trace = "N/A"
print "| " vuln_id " | " pkg " | " found_ver " | " fixed_ver " | " desc " | `" trace "` | [View](https://pkg.go.dev/vuln/" vuln_id ") |"
}
}
' vulnerability-check.report >> $GITHUB_STEP_SUMMARY
fi
test-code:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Dagger Version
id: dagger_version
uses: sagikazarmark/dagger-version-action@v0.0.1
- name: Run Tests
uses: dagger/dagger-for-github@v7
with:
version: ${{ steps.dagger_version.outputs.version }}
verb: call
args: test-report --source=. export --path=TestReport.json
- name: Summarize Tests
uses: robherley/go-test-action@v0.6.0
with:
fromJSONFile: TestReport.json
- name: Run Test Coverage Report
if: github.event_name == 'pull_request'
uses: dagger/dagger-for-github@v7
with:
version: ${{ steps.dagger_version.outputs.version }}
verb: call
args: test-coverage-report --source=. export --path=coverage-report.md
- name: Add coverage to step summary
if: github.event_name == 'pull_request'
run: cat coverage-report.md >> $GITHUB_STEP_SUMMARY
- name: Run Test Coverage
if: github.event_name == 'pull_request'
uses: dagger/dagger-for-github@v7
with:
version: ${{ steps.dagger_version.outputs.version }}
verb: call
args: test-coverage --source=. export --path=coverage.out
- uses: codecov/codecov-action@v5
if: github.event_name == 'pull_request'
with:
verbose: true
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- name: Build Binary
uses: dagger/dagger-for-github@v7
with:
version: ${{ steps.dagger_version.outputs.version }}
verb: call
args: build-dev --source=. --platform linux/amd64 export --path=./harbor-dev
push-latest-images:
needs:
- lint
- test-code
permissions:
contents: read
id-token: write
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- name: Print GitHub ref for debugging
run: |
echo "GitHub ref: $GITHUB_REF"
- name: Checkout repo
if: github.event_name == 'push' && (github.ref == 'refs/heads/main')
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Publish and Sign Snapshot Image
if: github.event_name == 'push' && (github.ref == 'refs/heads/main')
uses: ./.github/actions/publish-and-sign
with:
IMAGE_TAGS: latest
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
REGISTRY_ADDRESS: ${{ vars.REGISTRY_ADDRESS }}
REGISTRY_USERNAME: ${{ vars.REGISTRY_USERNAME }}
publish-release:
needs:
- lint
- test-code
permissions:
contents: write
packages: write
id-token: write
runs-on: ubuntu-latest
if: |
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')) ||
(github.event_name == 'workflow_dispatch')
steps:
- name: Checkout repo
if: |
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')) ||
(github.event_name == 'workflow_dispatch')
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.ref }}
- name: Create Build Dir
if: |
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')) ||
(github.event_name == 'workflow_dispatch')
run: mkdir -p dist
- name: Building Binaries
if: |
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')) ||
(github.event_name == 'workflow_dispatch')
uses: dagger/dagger-for-github@v7
with:
version: "latest"
verb: call
args: "build --build-dir=./dist export --path=./dist"
- name: Archiving Binaries
if: |
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')) ||
(github.event_name == 'workflow_dispatch')
uses: dagger/dagger-for-github@v7
with:
version: "latest"
verb: call
args: "archive --build-dir=./dist export --path=./dist"
- name: Building SBOM
if: |
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')) ||
(github.event_name == 'workflow_dispatch')
uses: dagger/dagger-for-github@v7
with:
version: "latest"
verb: call
args: "sbom --build-dir=./dist export --path=./dist"
- name: NFPM Build (deb/rpm)
if: |
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')) ||
(github.event_name == 'workflow_dispatch')
uses: dagger/dagger-for-github@v7
with:
version: "latest"
verb: call
args: "nfpm-build --build-dir=./dist export --path=./dist"
- name: APK Build (.apk)
if: |
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')) ||
(github.event_name == 'workflow_dispatch')
uses: dagger/dagger-for-github@v7
with:
version: "latest"
verb: call
args: "apk --build-dir=./dist export --path=./dist"
- name: Creating Checksum
if: |
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')) ||
(github.event_name == 'workflow_dispatch')
uses: dagger/dagger-for-github@v7
with:
version: "latest"
verb: call
args: "checksum --build-dir=./dist export --path=./dist"
- name: Publish Release
if: |
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')) ||
(github.event_name == 'workflow_dispatch')
uses: dagger/dagger-for-github@v7
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
version: "latest"
verb: call
args: "publish-release --build-dir=./dist --token=env://GITHUB_TOKEN "
- name: Apt Build
if: |
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')) ||
(github.event_name == 'workflow_dispatch')
uses: dagger/dagger-for-github@v7
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
version: "latest"
verb: call
args: "apt-build --build-dir=./dist --token=env://GITHUB_TOKEN "
- name: Upload Build Artifact
if: |
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')) ||
(github.event_name == 'workflow_dispatch')
uses: actions/upload-artifact@v4
with:
name: build-dir
path: ./dist
- name: Publish and Sign Tagged Image
if: |
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')) ||
(github.event_name == 'workflow_dispatch')
uses: ./.github/actions/publish-and-sign
with:
IMAGE_TAGS: "latest,${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.ref_name }}"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
REGISTRY_ADDRESS: ${{ vars.REGISTRY_ADDRESS }}
REGISTRY_USERNAME: ${{ vars.REGISTRY_USERNAME }}
BUILD_DIR: "dist"