From 728ed57e71341f7bbf8f9ef341c954798c54abc1 Mon Sep 17 00:00:00 2001 From: Aleksey Sabilin Date: Sat, 11 Jul 2026 15:10:05 +0300 Subject: [PATCH] Co-authored-by: --- .gitea/workflows/ci.yml | 9 +++++++++ .gitea/workflows/deploy-stage.yml | 11 +++++++++++ scripts/run-registry-prune.sh | 21 +++++++++++++++++++++ 3 files changed, 41 insertions(+) create mode 100644 scripts/run-registry-prune.sh diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 4a5dfe6..5fdc1a2 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -69,5 +69,14 @@ jobs: TAG="sha-${GITHUB_SHA:0:12}" docker tag eventhub-admin-ui:local "${REGISTRY}/eventhub-admin-ui:${TAG}" docker tag eventhub-admin-ui:local "${REGISTRY}/eventhub-admin-ui:ift" + docker tag eventhub-admin-ui:local "${REGISTRY}/eventhub-admin-ui:dev" bash scripts/retry-docker-build.sh 5 30 -- docker push "${REGISTRY}/eventhub-admin-ui:${TAG}" bash scripts/retry-docker-build.sh 5 30 -- docker push "${REGISTRY}/eventhub-admin-ui:ift" + bash scripts/retry-docker-build.sh 5 30 -- docker push "${REGISTRY}/eventhub-admin-ui:dev" + + - name: Prune old registry images + if: github.event_name == 'push' + env: + REGISTRY_USER: ${{ secrets.REGISTRY_USER }} + REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }} + run: bash scripts/run-registry-prune.sh diff --git a/.gitea/workflows/deploy-stage.yml b/.gitea/workflows/deploy-stage.yml index f0db252..2458aaf 100644 --- a/.gitea/workflows/deploy-stage.yml +++ b/.gitea/workflows/deploy-stage.yml @@ -41,11 +41,22 @@ jobs: 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}" + - name: Prune old registry images + env: + REGISTRY_USER: ${{ secrets.REGISTRY_USER }} + REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }} + run: bash scripts/run-registry-prune.sh + - name: Deploy admin on stage via SSH uses: appleboy/ssh-action@v0.1.5 with: diff --git a/scripts/run-registry-prune.sh b/scripts/run-registry-prune.sh new file mode 100644 index 0000000..3e3dade --- /dev/null +++ b/scripts/run-registry-prune.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash +# CI helper: clone EventHubDevOps и запустить prune-registry-images.sh +set -euo pipefail + +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 for registry prune" + 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/prune-registry-images.sh"