Tag images correctly #41
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 container image | |
on: | |
push: | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
cancel-in-progress: true | |
env: | |
BRANCH: ${{ github.head_ref || github.ref_name }} | |
jobs: | |
push_to_registry: | |
name: Push container image to GitHub Container Registry | |
runs-on: ubuntu-latest | |
steps: | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Generate tag name | |
run: | | |
if [[ ${BRANCH} == "main" ]]; then | |
IMAGE_TAG="latest" | |
else | |
IMAGE_TAG="${BRANCH/\//-}" | |
fi | |
echo "IMAGE_TAG=${IMAGE_TAG}" >> $GITHUB_ENV | |
- name: Build and push container image | |
uses: docker/build-push-action@v6 | |
with: | |
push: true | |
tags: ghcr.io/${{ github.repository }}:${{ env.IMAGE_TAG }} |