add possibility to add image version
This commit is contained in:
@@ -1,6 +1,12 @@
|
||||
name: Publish docker workflow
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
build_args:
|
||||
description: Optional docker build args. If VERSION is provided, it is also used as image tag.
|
||||
required: false
|
||||
type: string
|
||||
default: ''
|
||||
jobs:
|
||||
publish_docker:
|
||||
name: Build and publish docker image
|
||||
@@ -8,18 +14,37 @@ jobs:
|
||||
steps:
|
||||
- name: Checkout source code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup docker buildx environment
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Login to docker registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ${{ vars.CONTAINER_REGISTRY_URL }}
|
||||
username: ${{ vars.CONTAINER_REGISTRY_USERNAME }}
|
||||
password: ${{ secrets.CONTAINER_REGISTRY_TOKEN }}
|
||||
|
||||
- name: Resolve docker tag
|
||||
id: resolve_tag
|
||||
shell: bash
|
||||
env:
|
||||
INPUT_BUILD_ARGS: ${{ inputs.build_args }}
|
||||
run: |
|
||||
VERSION="$(printf '%s\n' "${INPUT_BUILD_ARGS}" | sed -n 's/^VERSION=//p' | head -n 1)"
|
||||
echo "Using VERSION: ${INPUT_BUILD_ARGS}"
|
||||
if [ -n "${VERSION}" ]; then
|
||||
IMAGE_TAG="${VERSION}"
|
||||
else
|
||||
IMAGE_TAG="latest"
|
||||
fi
|
||||
echo "image_tag=${IMAGE_TAG}"
|
||||
|
||||
- name: Build and push docker image
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
file: ./Dockerfile
|
||||
push: true
|
||||
tags: "${{ vars.CONTAINER_REGISTRY_URL }}/${{gitea.repository}}:latest"
|
||||
build-args: ${{ inputs.build_args }}
|
||||
tags: "${{ vars.CONTAINER_REGISTRY_URL }}/${{ gitea.repository }}:${{ steps.resolve_tag.outputs.IMAGE_TAG }}"
|
||||
|
||||
Reference in New Issue
Block a user