fix(ci): git reset --hard for staging deploy; fix rollback (BIT-22325) #23

Merged
spark merged 1 commits from task/BIT-21924-staging-smoke-seed into main 2026-05-14 19:38:43 +01:00
+3 -4
View File
@@ -45,7 +45,7 @@ jobs:
set -euo pipefail
BRANCH="${STAGING_GIT_BRANCH:?STAGING_GIT_BRANCH is required}"
bash tools/ci/gitea-actions-ssh-config.sh staging "$STAGING_HOST" "$STAGING_USER" "$STAGING_PORT" "$STAGING_SSH_KEY" "$STAGING_SSH_KNOWN_HOSTS"
ssh -F "${HOME}/.ssh/gitea_ci_staging.conf" staging "cd /opt/bitreport/ai-news-writer && git fetch origin && git pull --ff-only origin ${BRANCH} && npm ci --omit=dev"
ssh -F "${HOME}/.ssh/gitea_ci_staging.conf" staging "cd /opt/bitreport/ai-news-writer && git fetch origin && git checkout ${BRANCH} && git reset --hard origin/${BRANCH} && npm ci --omit=dev"
ssh -F "${HOME}/.ssh/gitea_ci_staging.conf" staging "cd /opt/bitreport/ai-news-writer && pm2 startOrReload ecosystem.config.cjs --update-env"
- name: Health check — staging
@@ -75,9 +75,8 @@ jobs:
BRANCH="${STAGING_GIT_BRANCH:?STAGING_GIT_BRANCH is required}"
bash tools/ci/gitea-actions-ssh-config.sh staging "$STAGING_HOST" "$STAGING_USER" "$STAGING_PORT" "$STAGING_SSH_KEY" "$STAGING_SSH_KNOWN_HOSTS"
echo "Attempting automatic rollback to previous commit..."
ssh -F "${HOME}/.ssh/gitea_ci_staging.conf" staging "cd /opt/bitreport/ai-news-writer && git log --oneline -2"
ssh -F "${HOME}/.ssh/gitea_ci_staging.conf" staging "cd /opt/bitreport/ai-news-writer && git revert HEAD -m 1 --no-edit && git push origin ${BRANCH}"
ssh -F "${HOME}/.ssh/gitea_ci_staging.conf" staging "cd /opt/bitreport/ai-news-writer && git fetch origin && git pull --ff-only origin ${BRANCH} && npm ci --omit=dev && pm2 startOrReload ecosystem.config.cjs --update-env"
ssh -F "${HOME}/.ssh/gitea_ci_staging.conf" staging "cd /opt/bitreport/ai-news-writer && git log --oneline -3"
ssh -F "${HOME}/.ssh/gitea_ci_staging.conf" staging "cd /opt/bitreport/ai-news-writer && git reset --hard HEAD@{1} && npm ci --omit=dev && pm2 startOrReload ecosystem.config.cjs --update-env"
echo "Staging deployment failed — rollback attempted"
exit 1