Skip to content

Commit 8e15e11

Browse files
Update build.yaml
1 parent 3710851 commit 8e15e11

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

.github/workflows/build.yaml

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,23 @@ jobs:
3232
run: |
3333
IMAGE_BASE=ghcr.io/${{ github.repository_owner }}/k8s-restart
3434
echo "IMAGE_LATEST=$IMAGE_BASE:latest" >> $GITHUB_OUTPUT
35-
if [[ -n "${{ github.event.inputs.version_tag }}" ]]; then
36-
echo "IMAGE_VERSION=$IMAGE_BASE:${{ github.event.inputs.version_tag }}" >> $GITHUB_OUTPUT
35+
36+
# Determine version tag
37+
if [[ "${{ github.event_name }}" == "workflow_dispatch" && -n "${{ github.event.inputs.version_tag }}" ]]; then
38+
VERSION_TAG="${{ github.event.inputs.version_tag }}"
39+
else
40+
VERSION_TAG="run-${{ github.run_id }}"
3741
fi
3842
43+
echo "IMAGE_VERSION=$IMAGE_BASE:$VERSION_TAG" >> $GITHUB_OUTPUT
44+
3945
- name: Build once and tag
4046
run: |
4147
docker build -t ${{ steps.vars.outputs.IMAGE_LATEST }} .
42-
if [ -n "${{ steps.vars.outputs.IMAGE_VERSION }}" ]; then
43-
docker tag ${{ steps.vars.outputs.IMAGE_LATEST }} ${{ steps.vars.outputs.IMAGE_VERSION }}
44-
fi
48+
docker tag ${{ steps.vars.outputs.IMAGE_LATEST }} ${{ steps.vars.outputs.IMAGE_VERSION }}
4549
4650
- name: Push all tags
4751
run: |
4852
docker push ${{ steps.vars.outputs.IMAGE_LATEST }}
49-
if [ -n "${{ steps.vars.outputs.IMAGE_VERSION }}" ]; then
50-
docker push ${{ steps.vars.outputs.IMAGE_VERSION }}
51-
fi
53+
docker push ${{ steps.vars.outputs.IMAGE_VERSION }}
54+

0 commit comments

Comments
 (0)