Jörn Guy Süß e2a6b19a2e fix: two tag extensions
Run docker build -t
ghcr.io/ghcr.io/jgsuess/fhirflare-ig-toolkit:main:latest .
ERROR: failed to build: invalid tag
"ghcr.io/ghcr.io/jgsuess/fhirflare-ig-toolkit:main:latest": invalid
reference format
2025-07-15 10:21:32 +10:00

53 lines
1.8 KiB
YAML

# This workflow builds and pushes a Docker image to GitHub Container Registry (ghcr.io) on every push to main.
#
# The Docker meta step is required because GitHub repository names can contain uppercase letters, but Docker image tags must be lowercase.
# The docker/metadata-action@v5 normalizes the repository name to lowercase, ensuring the build and push steps use a valid image tag.
#
# Without this normalization, you may encounter errors like:
# ERROR: failed to build: invalid tag "ghcr.io/jgsuess/FHIRFLARE-IG-Toolkit:latest": repository name must be lowercase
# Error: Process completed with exit code 1.
#
# This workflow uses the IMAGE_NAME environment variable set by the Docker meta step to guarantee a valid, lowercase image name.
name: Build and Push Docker image
on:
push:
branches:
- main
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}
- name: Set normalized image name
run: |
if [[ "${{ github.ref_name }}" == "main" ]]; then
echo "IMAGE_NAME=$(echo ${{ steps.meta.outputs.tags }} | sed 's/:main/:latest/')" >> $GITHUB_ENV
else
echo "IMAGE_NAME=${{ steps.meta.outputs.tags }}" >> $GITHUB_ENV
fi
- name: Build Docker image
run: |
docker build -t ${{ env.IMAGE_NAME }} .
- name: Push Docker image
run: |
docker push ${{ env.IMAGE_NAME }}