Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions .github/workflows/build-and-push-container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ name: Build and Push Container Image

on:
push:
branches:
- main
tags:
- "v*"
workflow_dispatch:
Expand Down Expand Up @@ -36,9 +38,19 @@ jobs:
id: tag
run: |
if [ "${{ github.event_name }}" = "push" ]; then
echo "tag=${GITHUB_REF_NAME}" >> $GITHUB_OUTPUT
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
# Tagged release: publish the version tag and move latest.
echo "tag=${GITHUB_REF_NAME}" >> $GITHUB_OUTPUT
echo "push_latest=true" >> $GITHUB_OUTPUT
else
# Push to main: publish a rolling edge tag plus an immutable sha tag.
echo "tag=edge" >> $GITHUB_OUTPUT
echo "sha_tag=sha-$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
echo "push_latest=false" >> $GITHUB_OUTPUT
fi
else
echo "tag=${{ inputs.tag }}" >> $GITHUB_OUTPUT
echo "push_latest=${{ inputs.add_latest }}" >> $GITHUB_OUTPUT
git checkout "refs/tags/${{ inputs.tag }}"
fi

Expand All @@ -60,5 +72,5 @@ jobs:
push: true
tags: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.tag.outputs.tag }}
${{ github.event_name == 'push' && format('{0}/{1}:latest', env.REGISTRY, env.IMAGE_NAME) || '' }}
${{ github.event_name == 'workflow_dispatch' && inputs.add_latest && format('{0}/{1}:latest', env.REGISTRY, env.IMAGE_NAME) || '' }}
${{ steps.tag.outputs.sha_tag != '' && format('{0}/{1}:{2}', env.REGISTRY, env.IMAGE_NAME, steps.tag.outputs.sha_tag) || '' }}
${{ steps.tag.outputs.push_latest == 'true' && format('{0}/{1}:latest', env.REGISTRY, env.IMAGE_NAME) || '' }}
Loading