-
Notifications
You must be signed in to change notification settings - Fork 94
88 lines (75 loc) · 2.59 KB
/
docker-build.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
83
84
85
86
87
88
name: Build and Push Docker Images
permissions:
id-token: write
contents: read
attestations: write
packages: write
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
service: [worker-cli]
include:
- service: worker-cli
dockerfile: docker/docker/worker-cli/Dockerfile
context: docker/docker/worker-cli
component: worker-cli
env:
REGISTRY: docker.io
IMAGE_NAME: tcosolutions/betterscan-${{ matrix.component }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/[email protected]
- name: Login to Docker Hub
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push Docker image
id: build-push
uses: docker/[email protected]
with:
context: ${{ matrix.context }}
file: ${{ matrix.dockerfile }}
platforms: linux/amd64, linux/arm64
push: true
tags: |
${{ env.IMAGE_NAME }}:latest
${{ env.IMAGE_NAME }}:${{ github.sha }}
- name: Generate artifact attestation
uses: actions/attest-build-provenance@v1
with:
subject-name: docker.io/${{ secrets.DOCKERHUB_USERNAME }}/betterscan-${{ matrix.component }}
subject-digest: ${{ steps.build-push.outputs.digest }}
push-to-registry: true
env:
DOCKER_HUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKER_HUB_PASSWORD: ${{ secrets.DOCKERHUB_TOKEN }}
# Install Grype
- name: Install Grype
run: |
curl -sSfL https://raw.githubusercontent.com/anchore/grype/main/install.sh | sh -s -- -b /usr/local/bin
# Generate SBOM with Grype
- name: Generate SBOM with Grype
run: |
grype ${{ env.IMAGE_NAME }}:${{ github.sha }} -o cyclonedx-json > sbom.cyclonedx.json
- name: Generate SBOM attestation
uses: actions/[email protected]
with:
subject-name: docker.io/${{ secrets.DOCKERHUB_USERNAME }}/betterscan-${{ matrix.component }}
subject-digest: ${{ steps.build-push.outputs.digest }}
sbom-path: 'sbom.cyclonedx.json'
push-to-registry: true
env:
DOCKER_HUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKER_HUB_PASSWORD: ${{ secrets.DOCKERHUB_TOKEN }}