From adc623796d02757426e34d1e5036a70c9af43c2a Mon Sep 17 00:00:00 2001 From: dresber Date: Sat, 9 May 2026 12:35:18 +0200 Subject: [PATCH] adopt docker build and push --- .gitea/workflows/docker-publish.yml | 46 ++++++++++++++++++++++------- 1 file changed, 35 insertions(+), 11 deletions(-) diff --git a/.gitea/workflows/docker-publish.yml b/.gitea/workflows/docker-publish.yml index f82d113..fe9104b 100644 --- a/.gitea/workflows/docker-publish.yml +++ b/.gitea/workflows/docker-publish.yml @@ -53,18 +53,42 @@ jobs: run: | echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login "${{ secrets.DOCKER_REGISTRY }}" -u "${{ secrets.REGISTRY_USERNAME }}" --password-stdin - - name: Build and Push - shell: bash + - name: Build image run: | - set -euo pipefail + SHA_SHORT="$(git rev-parse --short HEAD)" + FULL_IMAGE="${{ secrets.DOCKER_REGISTRY }}/${{ inputs.image_name }}" - export DOCKER_BUILDKIT=1 - docker build ${{ steps.vars.outputs.docker_tags }} ${{ inputs.dockerfile_path }} + docker build \ + -t "${FULL_IMAGE}:${SHA_SHORT}" \ + ${{ inputs.dockerfile_path }} - IMAGE="${{ steps.vars.outputs.full_image }}" - TAGS="${{ steps.vars.outputs.docker_tags }}" + if echo "${{ gitea.ref }}" | grep -q '^refs/tags/v'; then + VERSION="${{ gitea.ref_name }}" + VERSION="${VERSION#v}" + MAJOR="$(echo "$VERSION" | cut -d. -f1)" + MINOR="$(echo "$VERSION" | cut -d. -f1,2)" - echo "$TAGS" | tr ' ' '\n' | grep "^${IMAGE}:" | while read -r tag; do - echo "Pushing $tag" - docker push "$tag" - done \ No newline at end of file + docker tag "${FULL_IMAGE}:${SHA_SHORT}" "${FULL_IMAGE}:latest" + docker tag "${FULL_IMAGE}:${SHA_SHORT}" "${FULL_IMAGE}:${VERSION}" + docker tag "${FULL_IMAGE}:${SHA_SHORT}" "${FULL_IMAGE}:${MINOR}" + docker tag "${FULL_IMAGE}:${SHA_SHORT}" "${FULL_IMAGE}:${MAJOR}" + fi + + - name: Push image + run: | + SHA_SHORT="$(git rev-parse --short HEAD)" + FULL_IMAGE="${{ secrets.DOCKER_REGISTRY }}/${{ inputs.image_name }}" + + docker push "${FULL_IMAGE}:${SHA_SHORT}" + + if echo "${{ gitea.ref }}" | grep -q '^refs/tags/v'; then + VERSION="${{ gitea.ref_name }}" + VERSION="${VERSION#v}" + MAJOR="$(echo "$VERSION" | cut -d. -f1)" + MINOR="$(echo "$VERSION" | cut -d. -f1,2)" + + docker push "${FULL_IMAGE}:latest" + docker push "${FULL_IMAGE}:${VERSION}" + docker push "${FULL_IMAGE}:${MINOR}" + docker push "${FULL_IMAGE}:${MAJOR}" + fi \ No newline at end of file