Skip to content

Commit

Permalink
Publish Docker image to GitHub registry
Browse files Browse the repository at this point in the history
  • Loading branch information
michel-kraemer committed Nov 12, 2024
1 parent 9c8339f commit e884288
Showing 1 changed file with 64 additions and 0 deletions.
64 changes: 64 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Publish Docker image

on:
push:
branches:
- master
release:
types: [published]

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build:
runs-on: ubuntu-latest

permissions:
contents: read
packages: write

steps:
- uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
tags: |
type=ref,event=branch,enable=true
type=ref,event=tag,enable=true
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
push: true
# Set 'provenance: false' so there won't be a build for an unknown
# architecture (https://github.com/docker/build-push-action/issues/820)
# and calling delete-package-versions below will not result in an
# 'manifest unknown' error (https://github.com/actions/delete-package-versions/issues/90)
provenance: false
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=registry,ref=ghcr.io/${{ github.repository }}:latest
cache-to: type=inline

- name: Remove untagged container images
uses: actions/delete-package-versions@v5
with:
package-name: schwarzwald
package-type: container
delete-only-untagged-versions: true
min-versions-to-keep: 0

0 comments on commit e884288

Please sign in to comment.