Skip to content

Commit 0ba2ca9

Browse files
Refactor Dockerfile and workflow to create and publish a Docker image
1 parent 1fb24a3 commit 0ba2ca9

File tree

1 file changed

+20
-11
lines changed

1 file changed

+20
-11
lines changed

.github/workflows/publish_image.yaml

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,54 @@
1-
name: Publish Docker image
1+
#
2+
name: Create and publish a Docker image
23

34
on:
45
push:
5-
branches:
6-
- 'release/**'
6+
branches: ['release/*']
77

88
env:
99
REGISTRY: ghcr.io
1010
IMAGE_NAME: ${{ github.repository }}
1111

1212
jobs:
13-
build-and-push:
13+
build-and-push-image:
1414
runs-on: ubuntu-latest
15+
1516
permissions:
1617
contents: read
1718
packages: write
19+
attestations: write
20+
id-token: write
1821

1922
steps:
2023
- name: Checkout repository
21-
uses: actions/checkout@v3
24+
uses: actions/checkout@v4
2225

2326
- name: Log in to the Container registry
24-
uses: docker/login-action@v2
27+
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
2528
with:
2629
registry: ${{ env.REGISTRY }}
2730
username: ${{ github.actor }}
2831
password: ${{ secrets.GITHUB_TOKEN }}
2932

3033
- name: Extract metadata (tags, labels) for Docker
3134
id: meta
32-
uses: docker/metadata-action@v4
35+
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
3336
with:
3437
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
35-
tags: |
36-
type=ref,event=branch
37-
type=sha
3838

3939
- name: Build and push Docker image
40-
uses: docker/build-push-action@v4
40+
id: push
41+
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
4142
with:
4243
context: .
4344
push: true
4445
tags: ${{ steps.meta.outputs.tags }}
4546
labels: ${{ steps.meta.outputs.labels }}
47+
48+
- name: Generate artifact attestation
49+
uses: actions/attest-build-provenance@v1
50+
with:
51+
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
52+
subject-digest: ${{ steps.push.outputs.digest }}
53+
push-to-registry: true
54+

0 commit comments

Comments
 (0)