-
Notifications
You must be signed in to change notification settings - Fork 17
36 lines (33 loc) · 1.01 KB
/
release-image.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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