-
Notifications
You must be signed in to change notification settings - Fork 2
85 lines (74 loc) · 2.77 KB
/
build-image.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
name: image
on: # yamllint disable-line rule:truthy
push:
branches:
- main
paths:
- .github/workflows/build-image.yml
- ./images/amd64.dockerfile
pull_request:
paths:
- .github/workflows/build-image.yml
- ./images/amd64.dockerfile
workflow_dispatch:
jobs:
image_build:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
attestations: write
packages: write
strategy:
fail-fast: false
matrix:
include:
- IMAGE_NAME: afxdp-dp-plugin
IMAGE_FILE: ./images/amd64.dockerfile
PLATFORMS: linux/amd64
LABEL: latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
# NOTE: setting fetch-depth to 0 to retrieve the entire history
# instead of a shallow-clone so that all tags are fetched as well.
# This is necessary for computing the VERSION using `git describe`
fetch-depth: 0
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
image: tonistiigi/binfmt:qemu-v8.1.5
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Set up cosign
uses: sigstore/cosign-installer@main
- name: Login to Quay
if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}
uses: docker/login-action@v3
with:
registry: quay.io/afxdp-plugins-for-kubernete
username: ${{ secrets.quay_username }}
password: ${{ secrets.quay_robot_token }}
- name: Build and (conditionally) push image
id: build-push-image
uses: docker/build-push-action@v6
with:
context: .
platforms: ${{ matrix.PLATFORMS }}
push: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}
tags: quay.io/afxdp-plugins-for-kubernete/${{ matrix.IMAGE_NAME }}:${{ matrix.LABEL }}
labels: ${{ matrix.LABEL }}
build-args: ${{matrix.BUILD_ARGS}}
file: ${{ matrix.IMAGE_FILE }}
- name: Sign images with GitHub OIDC Token
if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}
run: |
cosign sign -y quay.io/afxdp-plugins-for-kubernete/${{ matrix.IMAGE_NAME }}:${{ matrix.LABEL }}@${{ steps.build-push-image.outputs.digest }}
- name: Generate image attestation
if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}
uses: actions/attest-build-provenance@v2
with:
subject-name: quay.io/afxdp-plugins-for-kubernete/${{ matrix.IMAGE_NAME }}
subject-digest: ${{ steps.build-push-image.outputs.digest }}
push-to-registry: true