Skip to content

Commit ff1a1fd

Browse files
committed
feat: update Docker workflow to build and publish images with artifact attestation
1 parent 6e47538 commit ff1a1fd

File tree

1 file changed

+43
-9
lines changed

1 file changed

+43
-9
lines changed

.github/workflows/build-docker.yml

Lines changed: 43 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,51 @@
1-
name: Build Docker Image
1+
name: Build and Publish Docker Image
22

33
on:
44
push:
5-
branches:
6-
- main
7-
pull_request:
5+
tags:
6+
- "v*"
7+
8+
env:
9+
REGISTRY: ghcr.io
10+
IMAGE_NAME: ${{ github.repository }}
811

912
jobs:
10-
build:
13+
build-and-push-image:
1114
runs-on: ubuntu-latest
15+
permissions:
16+
contents: read
17+
packages: write
18+
attestations: write
19+
id-token: write
1220
steps:
13-
- name: Checkout
14-
uses: actions/checkout@v4
21+
- name: Checkout repository
22+
uses: actions/checkout@v5
23+
24+
- name: Log in to the Container registry
25+
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
26+
with:
27+
registry: ${{ env.REGISTRY }}
28+
username: ${{ github.actor }}
29+
password: ${{ secrets.GITHUB_TOKEN }}
30+
31+
- name: Extract metadata (tags, labels) for Docker
32+
id: meta
33+
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
34+
with:
35+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
36+
37+
- name: Build and push Docker image
38+
id: push
39+
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
40+
with:
41+
context: .
42+
push: true
43+
tags: ${{ steps.meta.outputs.tags }}
44+
labels: ${{ steps.meta.outputs.labels }}
1545

16-
- name: Build Docker image
17-
run: docker build -t webhook-router .
46+
- name: Generate artifact attestation
47+
uses: actions/attest-build-provenance@v3
48+
with:
49+
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
50+
subject-digest: ${{ steps.push.outputs.digest }}
51+
push-to-registry: true

0 commit comments

Comments
 (0)