Update deploy-image.yml to handle tag-based deployments and dynamically compute image tags
This commit is contained in:
@@ -2,6 +2,8 @@ name: Build and Push Docker Image
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
|
tags:
|
||||||
|
- 'v*'
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
@@ -16,7 +18,6 @@ jobs:
|
|||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Compute image name and tag
|
- name: Compute image name and tag
|
||||||
id: meta
|
|
||||||
run: |
|
run: |
|
||||||
REGISTRY=$(echo "${{ github.server_url }}" | sed 's|https\?://||')
|
REGISTRY=$(echo "${{ github.server_url }}" | sed 's|https\?://||')
|
||||||
OWNER=$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]')
|
OWNER=$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]')
|
||||||
@@ -25,8 +26,8 @@ jobs:
|
|||||||
FULL_IMAGE="${REGISTRY}/${OWNER}/${IMAGE_NAME}"
|
FULL_IMAGE="${REGISTRY}/${OWNER}/${IMAGE_NAME}"
|
||||||
|
|
||||||
REF="${{ github.ref_name }}"
|
REF="${{ github.ref_name }}"
|
||||||
if [ "${REF}" = "main" ]; then
|
if [[ "${REF}" == v* ]]; then
|
||||||
TAG="latest"
|
TAG="${REF#v}"
|
||||||
else
|
else
|
||||||
TAG=$(echo "${REF}" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9._-]/-/g')
|
TAG=$(echo "${REF}" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9._-]/-/g')
|
||||||
fi
|
fi
|
||||||
@@ -62,4 +63,4 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
push: true
|
push: true
|
||||||
tags: git.mein-gateway.de/thischwa/javadocviewerservice:develop
|
tags: ${{ steps.metai.outputs.image }}:${{ steps.metai.outputs.tag }}
|
||||||
Reference in New Issue
Block a user