Skip to content

Commit e4d8b72

Browse files
committed
Add support for publishing to GitHub Container Registry
Set up GitHub Container Registry as an additional target for Docker images with corresponding login and metadata configuration. This ensures images are published to both Docker Hub and GitHub Container Registry, including proper attestations and metadata. Signed-off-by: Moritz Friedrich <moritz@matchory.com>
1 parent 66df707 commit e4d8b72

1 file changed

Lines changed: 24 additions & 4 deletions

File tree

.github/workflows/docker.yaml

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ on:
1111
# Runs every Monday at 03:00 UTC
1212
- cron: '0 3 * * 1'
1313

14+
env:
15+
REGISTRY: ghcr.io
16+
1417
permissions:
1518
contents: read
1619
packages: write
@@ -167,12 +170,19 @@ jobs:
167170
- name: Set up Docker Buildx
168171
uses: docker/setup-buildx-action@v3
169172

170-
- name: Log in to Docker Hub
173+
- name: Login to Docker Hub
171174
uses: docker/login-action@v3
172175
with:
173-
username: ${{ secrets.DOCKER_USERNAME || vars.DOCKER_USERNAME || github.repository_owner }}
176+
username: ${{ vars.DOCKER_USERNAME }}
174177
password: ${{ secrets.DOCKER_PASSWORD }}
175178

179+
- name: Login to Container Registry
180+
uses: docker/login-action@v3
181+
with:
182+
registry: ${{ env.REGISTRY }}
183+
username: ${{ github.actor }}
184+
password: ${{ secrets.GITHUB_TOKEN }}
185+
176186
- name: Determine Image Name
177187
id: image_name
178188

@@ -191,10 +201,13 @@ jobs:
191201
id: meta
192202
uses: docker/metadata-action@v5
193203
with:
194-
images: ${{ env.IMAGE_NAME }}
204+
images: |
205+
${{ env.IMAGE_NAME }}
206+
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
195207
labels: |
196208
org.opencontainers.image.title=${{ env.IMAGE_NAME }}
197209
org.opencontainers.image.version=${{ env.VERSION }}
210+
org.opencontainers.vendor="Matchory GmbH"
198211
tags: |
199212
type=sha
200213
type=sha,prefix=${{ env.VERSION }}-
@@ -217,9 +230,16 @@ jobs:
217230
provenance: mode=max
218231
sbom: true
219232

220-
- name: Generate artifact attestation
233+
- name: Generate artifact attestation for Docker Hub
221234
uses: actions/attest-build-provenance@v2
222235
with:
223236
subject-name: index.docker.io/${{ env.IMAGE_NAME }}
224237
subject-digest: ${{ steps.build.outputs.digest }}
225238
push-to-registry: true
239+
240+
- name: Generate artifact attestation
241+
uses: actions/attest-build-provenance@v2
242+
with:
243+
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
244+
subject-digest: ${{ steps.build.outputs.digest }}
245+
push-to-registry: true

0 commit comments

Comments
 (0)