Skip to content

Publish Docker image #61

Publish Docker image

Publish Docker image #61

Workflow file for this run

name: Publish Docker image
on:
workflow_dispatch:
release:
types: [published]
jobs:
push_to_registry:
name: Push Docker image to GitHub Packages
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Prepare tags
id: prepare_tags
run: |
REPOSITORY=ghcr.io
DOCKER_IMAGE=tchapi/davis
VERSION=edge
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
fi
TAGS="${REPOSITORY}/${DOCKER_IMAGE}:${VERSION}"
if [ "${{ github.event_name }}" = "push" ]; then
TAGS="$TAGS,${REPOSITORY}/${DOCKER_IMAGE}:sha-${GITHUB_SHA::8}"
fi
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "tags=${TAGS}" >> $GITHUB_OUTPUT
echo "created=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT
-
name: Set up QEMU
uses: docker/setup-qemu-action@v2
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Extract metadata
id: meta
uses: docker/metadata-action@v4
with:
images: "tchapi/davis"
-
name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Build and Push to GitHub Packages
id: docker_build
uses: docker/build-push-action@v5
with:
platforms: linux/amd64,linux/arm64
file: docker/Dockerfile
pull: true
push: true
tags: ${{ steps.prepare_tags.outputs.tags }}
annotations: ${{ steps.meta.outputs.annotations }}
labels: |
org.opencontainers.image.source=${{ github.event.repository.html_url }}
org.opencontainers.image.created=${{ steps.prepare_tags.outputs.created }}
org.opencontainers.image.version=${{ steps.prepare_tags.outputs.version }}
org.opencontainers.image.revision=${{ github.sha }}