Skip to content

Commit 7084d89

Browse files
committed
Add Docker package workflow
1 parent c514515 commit 7084d89

File tree

1 file changed

+79
-0
lines changed

1 file changed

+79
-0
lines changed
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# https://docs.github.com/en/actions/use-cases-and-examples/publishing-packages/publishing-docker-images
2+
3+
name: Docker Package
4+
5+
on:
6+
workflow_dispatch:
7+
push:
8+
branches:
9+
- master
10+
tags:
11+
- 'v*'
12+
- 'release-*'
13+
pull_request:
14+
branches:
15+
- master
16+
17+
env:
18+
# Use docker.io for Docker Hub if empty
19+
REGISTRY: ghcr.io
20+
# github.repository as <account>/<repo>
21+
IMAGE_NAME: ${{ github.repository }}
22+
23+
jobs:
24+
package:
25+
runs-on: ubuntu-latest
26+
27+
# Sets the permissions granted to the GITHUB_TOKEN for the actions in this job.
28+
permissions:
29+
contents: read
30+
packages: write
31+
attestations: write
32+
id-token: write
33+
34+
steps:
35+
- name: Checkout repository
36+
uses: actions/checkout@v4
37+
38+
# https://github.com/docker/login-action
39+
- name: Log in to the Container registry ${{ env.REGISTRY }}
40+
uses: docker/login-action@v3
41+
with:
42+
registry: ${{ env.REGISTRY }}
43+
username: ${{ github.actor }}
44+
# https://docs.github.com/en/actions/security-for-github-actions/security-guides/automatic-token-authentication
45+
password: ${{ secrets.GITHUB_TOKEN }}
46+
47+
# https://github.com/docker/metadata-action
48+
- name: Extract metadata (tags, labels) for Docker
49+
id: meta
50+
uses: docker/metadata-action@v5
51+
with:
52+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
53+
# generate Docker tags based on the following events/attributes
54+
tags: |
55+
# set latest tag for master branch
56+
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'master') }}
57+
type=ref,event=tag
58+
type=ref,event=pr
59+
type=sha
60+
61+
# https://github.com/docker/build-push-action
62+
- name: Build and push Docker image
63+
id: push
64+
uses: docker/build-push-action@v6
65+
with:
66+
context: .
67+
push: true
68+
file: ./provisioning/Dockerfile
69+
tags: ${{ steps.meta.outputs.tags }}
70+
labels: ${{ steps.meta.outputs.labels }}
71+
72+
# https://github.com/actions/attest-build-provenance
73+
- name: Generate artifact attestation
74+
uses: actions/attest-build-provenance@v2
75+
with:
76+
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
77+
subject-digest: ${{ steps.push.outputs.digest }}
78+
# https://github.com/actions/attest-build-provenance/issues/71#issuecomment-2108140285
79+
push-to-registry: false

0 commit comments

Comments
 (0)