Skip to content

Release image

Release image #19

name: Release image
on:
push:
tags:
- v*
workflow_dispatch:
jobs:
build:
name: Publish image
runs-on: ubuntu-latest
env:
IMG_NAME: pod-graceful-drain
steps:
- uses: actions/checkout@v4
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- run: |
docker build --file docker/build.Dockerfile \
--tag "$IMG_NAME:latest" \
.
- name: Tag and push
run: |
GIT_VERSION=$(git describe --tags --dirty --always)
REGISTRY=ghcr.io/${{ github.repository_owner }}
tag-and-push() { docker tag $1 $2 && docker push $2; }
tag-and-push $IMG_NAME:latest $REGISTRY/$IMG_NAME:$GIT_VERSION
LATEST_TAG="$(git describe --tags --dirty --always --abbrev=0)"
if git diff --quiet "$LATEST_TAG"; then
tag-and-push $IMG_NAME:latest $REGISTRY/$IMG_NAME:latest
fi