From 9cc4d6b85df2413625efdd36490009502db0df13 Mon Sep 17 00:00:00 2001 From: Aleksey Sabilin Date: Sat, 11 Jul 2026 15:41:34 +0300 Subject: [PATCH] Co-authored-by: --- .gitea/workflows/deploy-stage.yml | 24 +++++++----------------- scripts/run-promote-images.sh | 26 ++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 17 deletions(-) create mode 100644 scripts/run-promote-images.sh diff --git a/.gitea/workflows/deploy-stage.yml b/.gitea/workflows/deploy-stage.yml index 2458aaf..176efb7 100644 --- a/.gitea/workflows/deploy-stage.yml +++ b/.gitea/workflows/deploy-stage.yml @@ -32,24 +32,14 @@ jobs: password: ${{ secrets.REGISTRY_PASSWORD }} - name: Promote admin-ui image (no rebuild) + env: + REGISTRY_USER: ${{ secrets.REGISTRY_USER }} + REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }} run: | - set -euo pipefail - SHA="${{ steps.meta.outputs.sha_tag }}" - REL="${{ steps.meta.outputs.release_tag }}" - if ! docker buildx imagetools inspect "${REGISTRY}/eventhub-admin-ui:${SHA}" >/dev/null 2>&1; then - echo "Образ eventhub-admin-ui:${SHA} не найден." - echo "Сначала прогоните IFT deploy для этого коммита (push в master)." - exit 1 - fi - if docker buildx imagetools inspect "${REGISTRY}/eventhub-admin-ui:stage" >/dev/null 2>&1; then - docker buildx imagetools create \ - -t "${REGISTRY}/eventhub-admin-ui:stage-previous" \ - "${REGISTRY}/eventhub-admin-ui:stage" - fi - docker buildx imagetools create \ - -t "${REGISTRY}/eventhub-admin-ui:${REL}" \ - -t "${REGISTRY}/eventhub-admin-ui:stage" \ - "${REGISTRY}/eventhub-admin-ui:${SHA}" + bash scripts/run-promote-images.sh \ + "${{ steps.meta.outputs.sha_tag }}" \ + "${{ steps.meta.outputs.release_tag }}" \ + stage - name: Prune old registry images env: diff --git a/scripts/run-promote-images.sh b/scripts/run-promote-images.sh new file mode 100644 index 0000000..4b286ad --- /dev/null +++ b/scripts/run-promote-images.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash +# CI: clone EventHubDevOps и promote-images.sh (admin-ui) +set -euo pipefail + +SHA_TAG="${1:?sha-tag}" +RELEASE_TAG="${2:?release-tag}" +STAND_ALIAS="${3:-stage}" + +DEVOPS_REPO="${DEVOPS_REPO:-https://git.sabilin.com/EventHub/EventHubDevOps.git}" +DEVOPS_REF="${DEVOPS_REF:-master}" + +if [[ -z "${REGISTRY_USER:-}" || -z "${REGISTRY_PASSWORD:-}" ]]; then + echo "REGISTRY_USER/PASSWORD required" + exit 1 +fi + +WORKDIR="$(mktemp -d)" +trap 'rm -rf "${WORKDIR}"' EXIT + +repo_path="${DEVOPS_REPO#https://}" +git clone --depth 1 --branch "${DEVOPS_REF}" \ + "https://${REGISTRY_USER}:${REGISTRY_PASSWORD}@${repo_path}" \ + "${WORKDIR}/devops" + +bash "${WORKDIR}/devops/scripts/promote-images.sh" \ + "${SHA_TAG}" "${RELEASE_TAG}" "${STAND_ALIAS}" eventhub-admin-ui