Skip to content

Commit ba4409b

Browse files
GitHub Action to publish Docker image to GHCR
1 parent a1243fb commit ba4409b

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

.github/workflows/docker-publish.yml

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Build and publish Docker image
2+
3+
on:
4+
push:
5+
branches: ['release']
6+
7+
env:
8+
REGISTRY: ghcr.io
9+
IMAGE_NAME: ${{ github.repository }}
10+
SCCACHE_GHA_ENABLED: on
11+
12+
jobs:
13+
build-and-push-image:
14+
runs-on: ubuntu-latest
15+
16+
permissions:
17+
content: read
18+
packages: write
19+
attestations: write
20+
id-token: write
21+
22+
steps:
23+
- name: checkout
24+
uses: actions/checkout@v4
25+
26+
- name: log in to registry
27+
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
28+
with:
29+
registry: ${{ env.REGISTRY }}
30+
username: ${{ github.actor }}
31+
password: ${{ secrets.GITHUB_TOKEN }}
32+
33+
- name: extract metadata
34+
id: meta
35+
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
36+
with:
37+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
38+
39+
- name: build and push docker image
40+
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
41+
with:
42+
context: .
43+
push: true
44+
tags: ${{ steps.meta.outputs.tags }}
45+
labels: ${{ steps.meta.outputs.labels }}
46+
47+
- name: Generate artifact attestation
48+
uses: actions/attest-build-provenance@v1
49+
with:
50+
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
51+
subject-digest: ${{ steps.push.outputs.digest }}
52+
push-to-registry: true

0 commit comments

Comments
 (0)