diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml index 2028d36..a65e761 100644 --- a/.gitea/workflows/build.yml +++ b/.gitea/workflows/build.yml @@ -83,10 +83,15 @@ jobs: DEPLOY_USER: ${{ secrets.REGISTRY_USER }} run: | REPO_URL="http://${DEPLOY_USER}:${DEPLOY_TOKEN}@gitea-http.gitea.svc.cluster.local:3000/sova/sova-deploy.git" - git clone "${REPO_URL}" - cd sova-deploy ENV="${{ needs.parse-tag.outputs.env }}" TAG="${{ needs.parse-tag.outputs.full_tag }}" + case "${ENV}" in + test|stage|prod) ;; + *) echo "Unknown env from tag: ${ENV}"; exit 1 ;; + esac + git clone --branch "${ENV}" --single-branch "${REPO_URL}" sova-deploy 2>/dev/null \ + || { git clone "${REPO_URL}" sova-deploy && cd sova-deploy && git checkout -B "${ENV}"; } + cd sova-deploy git config user.email "ci-bot@sova.local" git config user.name "sova-ci" MAX_RETRIES=5 @@ -98,14 +103,14 @@ jobs: curl -sSL -o /usr/local/bin/yq "https://github.com/mikefarah/yq/releases/download/v4.44.3/yq_linux_${YQ_ARCH}" chmod +x /usr/local/bin/yq for attempt in $(seq 1 $MAX_RETRIES); do - git pull --rebase "${REPO_URL}" main + git pull --rebase origin "${ENV}" yq -i ".image.repository = \"${IMAGE_DEPLOY}\"" "apps/adminpanel/values-${ENV}.yaml" yq -i ".image.tag = \"${TAG}\"" "apps/adminpanel/values-${ENV}.yaml" yq -i ".image.pullPolicy = \"IfNotPresent\"" "apps/adminpanel/values-${ENV}.yaml" git add "apps/adminpanel/values-${ENV}.yaml" git diff --cached --quiet && { echo "No changes"; exit 0; } git commit -m "chore(adminpanel): bump ${ENV} to ${TAG}" - if git push "${REPO_URL}" main; then + if git push origin "${ENV}"; then echo "Push OK on attempt ${attempt}" exit 0 fi