Release image #18
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: 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.repository_owner }} | |
password: ${{ secrets.CR_PAT }} | |
- 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 |