Skip to content

Workflow file for this run

name: Build and Publish Docker image to GHCR
on:
workflow_dispatch: # allows manual triggers via the GitHub UI
push:
branches:
- 364-publish-docker-image
release:
types:
- published
jobs:
build:
runs-on: ubuntu-latest
steps:
# Checkout the repository
- name: Checkout repository
uses: actions/checkout@v3
# Set up Docker Buildx for cross-platform builds (optional but recommended)
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# Log in to the GitHub Container Registry
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Build and tag the Docker image
- name: Build Docker image
run: |
cd hefquin-docker/
docker build -t ghcr.io/liusemweb/hefquin:latest .
# Get the tags for the current commit and add to image
echo "Find tags"
tags=$(git tag --points-at HEAD)
# Check if there are any tags
if [ -z "$tags" ]; then
echo "No tags found for the current commit."
else
# Loop through the tags line by line
echo "$tags" | while read -r tag; do
echo "Adding tag: $tag"
docker tag ghcr.io/liusemweb/hefquin:latest ghcr.io/liusemweb/hefquin:$tag
done
fi
# Push the Docker image to GitHub Container Registry (GHCR)
- name: Push Docker image to GHCR
run: |
docker push ghcr.io/liusemweb/hefquin --all-tags