-
Notifications
You must be signed in to change notification settings - Fork 0
65 lines (61 loc) · 2.03 KB
/
Copy pathbuild.yml
File metadata and controls
65 lines (61 loc) · 2.03 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
name: Build
on:
pull_request:
branches:
- main
paths: [src/**/*, main.py, requirements.txt, Dockerfile]
workflow_call: {}
env:
SHA: ${{ github.sha }}
jobs:
build:
name: Build Docker images
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: |
${{ github.repository }}
ghcr.io/${{ github.repository }}
tags: |
type=raw,value=${{ env.SHA }}
type=raw,value=latest
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build Docker images
uses: docker/build-push-action@v5
with:
context: .
push: false
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
outputs: type=docker,dest=/tmp/${{ github.event.repository.name }}-${{ env.SHA }}.tar
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ github.event.repository.name }}-${{ env.SHA }}
path: /tmp/${{ github.event.repository.name }}-${{ env.SHA }}.tar
scan:
name: Scan Docker images
runs-on: ubuntu-24.04
needs: [build]
steps:
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: ${{ github.event.repository.name }}-${{ env.SHA }}
path: /tmp
- name: Load image
run: |
docker load --input /tmp/${{ github.event.repository.name }}-${{ env.SHA }}.tar
- name: Find vulnerabilities
run: |
docker run -v /var/run/docker.sock:/var/run/docker.sock \
anchore/grype:v0.91.0 docker:${{ github.repository }}:${{ env.SHA }} -o table \
--fail-on critical --scope all-layers --add-cpes-if-none --by-cve --show-suppressed