0.2.15 #26
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish Docker image | |
on: | |
release: | |
types: [published] | |
jobs: | |
push_to_registries: | |
name: Build and publish Docker image | |
runs-on: ubuntu-latest | |
steps: | |
- | |
name: Check out the repo | |
uses: actions/checkout@v4 | |
- | |
name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- | |
name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- | |
name: Prepare | |
# In this preparation step, a few configurations are made | |
# according to tags that will be used to export the image | |
# for Docker Hub, as well as the name of the image itself | |
id: prep | |
run: | | |
DOCKER_IMAGE=ghcr.io/msk-access/biometrics | |
VERSION=noop | |
if [ "${{ github.event_name }}" = "schedule" ]; then | |
VERSION=nightly | |
elif [[ $GITHUB_REF == refs/tags/* ]]; then | |
VERSION=${GITHUB_REF#refs/tags/} | |
elif [[ $GITHUB_REF == refs/heads/* ]]; then | |
VERSION=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g') | |
fi | |
TAGS="${DOCKER_IMAGE}:${VERSION}" | |
if [[ $VERSION =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then | |
MINOR=${VERSION%.*} | |
MAJOR=${MINOR%.*} | |
TAGS="$TAGS,${DOCKER_IMAGE}:${MINOR},${DOCKER_IMAGE}:${MAJOR},${DOCKER_IMAGE}:latest" | |
elif [[ $VERSION =~ ^v[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then | |
VERSION=$(echo ${VERSION#v}) | |
TAGS="${DOCKER_IMAGE}:${VERSION}" | |
elif [ "${{ github.event_name }}" = "push" ]; then | |
TAGS="$TAGS,${DOCKER_IMAGE}:sha-${GITHUB_SHA::8}" | |
fi | |
echo ::set-output name=version::${VERSION} | |
echo ::set-output name=tags::${TAGS} | |
- | |
name: Login to GitHub Container Registry | |
#if: github.event_name != 'pull_request' | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.RS_PAT }} | |
- name: Push to GitHub Packages | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: ./Dockerfile | |
registry: ghcr.io | |
push: true | |
tags: ${{ steps.prep.outputs.tags }} | |
build-args: | | |
BIOMETRICS_VERSION=${{ steps.prep.outputs.version }} | |
labels: | | |
org.opencontainers.image.title=${{ github.event.repository.name }} | |
org.opencontainers.image.description=${{ github.event.repository.description }} | |
org.opencontainers.image.version=${{ steps.prep.outputs.version }} |