-
Notifications
You must be signed in to change notification settings - Fork 4
78 lines (64 loc) · 2.42 KB
/
build_util.yml
File metadata and controls
78 lines (64 loc) · 2.42 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
# This action produces a docker artifact of my utility pod used in k8s.
name: Build Util Container
on:
push:
branches: ['release']
workflow_dispatch:
jobs:
trivy:
name: Trivy Security Scan
if: github.event_name != 'pull_request' || !github.event.pull_request.draft
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Run Trivy vulnerability scanner in repo mode
uses: aquasecurity/trivy-action@v0.35.0
with:
format: "sarif"
output: "trivy-results.sarif"
ignore-unfixed: true
scan-type: "fs"
scanners: "vuln,secret"
severity: "CRITICAL,HIGH"
- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v4
with:
sarif_file: "trivy-results.sarif"
build-and-push-image:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Github Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v4
with:
images: ghcr.io/${{ github.actor }}/util
tags: release
- name: Build and push Docker image
uses: docker/build-push-action@v3
with:
context: ./utility-pod
file: ./utility-pod/Dockerfile
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
# would prefer to scan the image BEFORE it's uploaded, but I've not been able to find a hook in the build-push-action that would allow this to happen
# TODO: rather than using the build-push-action break the steps up with just a docker build / scan / docker push method.
- name: Scan image
run: |
docker images
curl -sSfL https://raw.githubusercontent.com/anchore/grype/main/install.sh | sh -s -- -b /usr/local/bin
grype ghcr.io/${{ github.actor }}/util:release --platform linux/amd64
grype ghcr.io/${{ github.actor }}/util:release --platform linux/arm64