-
-
Notifications
You must be signed in to change notification settings - Fork 7
82 lines (78 loc) · 2.71 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
name: ci
on:
push:
branches:
- "main"
tags:
- "v*"
pull_request:
env:
REGISTRY_IMAGE: karlderkaefer/cdk-notifier
jobs:
test:
runs-on: ubuntu-latest
name: test
steps:
- uses: actions/checkout@v4
- name: Setup go
uses: actions/setup-go@v5
with:
cache: true
go-version-file: "go.mod"
- run: go build .
- run: go test -short ./... -v -race -coverprofile=coverage.txt -covermode=atomic
env:
BITBUCKET_TEST_TOKEN: ${{ secrets.BITBUCKET_TEST_TOKEN }}
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
docker-build:
runs-on: ubuntu-latest
permissions:
packages: write
security-events: write
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY_IMAGE }}
tags: |
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=raw,value=latest,enable=${{ github.ref_name == 'main' }}
- name: Login to container Registry
if: ${{ (github.ref_name == 'main' || startsWith(github.ref, 'refs/tags/')) && github.repository_owner == 'karlderkaefer' }}
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- uses: docker/build-push-action@v6
with:
context: .
# push only on main or on tags
push: ${{ (github.ref_name == 'main' || startsWith(github.ref, 'refs/tags/')) && github.repository_owner == 'karlderkaefer' }}
platforms: linux/amd64,linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Analyze for critical and high CVEs
id: docker-scout-cves
if: ${{ github.event_name != 'pull_request_target' && github.event_name != 'pull_request' && github.ref_name == 'main' }}
uses: docker/scout-action@v1
with:
command: cves
image: ${{ steps.meta.outputs.tags }}
sarif-file: sarif.output.json
summary: true
- name: Upload SARIF result
id: upload-sarif
if: ${{ github.event_name != 'pull_request_target' && github.event_name != 'pull_request' && github.ref_name == 'main' }}
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: sarif.output.json