**Migration Complete:** - Removed GitLab CI/CD configuration (.gitlab-ci.yml) - Created Gitea Actions workflows (.gitea/workflows/) - Disabled automatic production deployment (manual only) - Added pre-production deployment to CT109 Docker container **New Workflows:** - build-and-deploy.yml: Main CI/CD pipeline with CT109 deployment - rollback.yml: Manual rollback capability - README.md: Comprehensive workflow documentation **Pre-Production Environment (CT109):** - Host: 10.0.0.51 - User: sysadmin - Port: 22 - Deploys on push to development/main branches - Access URL: http://ct109.local:5100 **Documentation:** - CI_CD_MIGRATION_GITEA.md: Complete migration guide - CI_CD_CT109_PREPRODUCTION.md: CT109 deployment architecture - GITEA_SECRETS_SETUP_GUIDE.md: Secrets configuration instructions **Git Remote Updated:** - Migrated from GitLab (gitlab.silverlabs.uk) to Gitea (git.silverlabs.uk) - Using token authentication for push/pull operations **Next Steps:** 1. Push code to Gitea to create repository 2. Add CT109 secrets via Gitea UI (CT109_HOST, CT109_SSH_PORT, CT109_USER, CT109_SSH_KEY) 3. Test pre-production deployment workflow 🚀 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
112 lines
3.7 KiB
YAML
112 lines
3.7 KiB
YAML
name: Rollback Deployment
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
inputs:
|
|
environment:
|
|
description: 'Environment to rollback'
|
|
required: true
|
|
type: choice
|
|
options:
|
|
- production
|
|
- development
|
|
version:
|
|
description: 'Version/tag to rollback to (leave empty for previous)'
|
|
required: false
|
|
type: string
|
|
|
|
jobs:
|
|
rollback:
|
|
name: Rollback to Previous Version
|
|
runs-on: ubuntu-latest
|
|
environment:
|
|
name: ${{ github.event.inputs.environment }}
|
|
steps:
|
|
- name: Set up SSH
|
|
run: |
|
|
mkdir -p ~/.ssh
|
|
chmod 700 ~/.ssh
|
|
echo "${{ secrets.VPS_SSH_KEY }}" > ~/.ssh/deploy_key
|
|
chmod 600 ~/.ssh/deploy_key
|
|
ssh-keyscan -p ${{ secrets.VPS_PORT }} ${{ secrets.VPS_HOST }} >> ~/.ssh/known_hosts 2>/dev/null
|
|
|
|
- name: Rollback deployment
|
|
run: |
|
|
ssh -i ~/.ssh/deploy_key -p ${{ secrets.VPS_PORT }} ${{ secrets.VPS_USER }}@${{ secrets.VPS_HOST }} bash -s << 'ENDSSH'
|
|
set -e
|
|
cd /opt/littleshop
|
|
|
|
VERSION="${{ github.event.inputs.version }}"
|
|
if [ -z "$VERSION" ]; then
|
|
echo "No version specified, using 'previous' tag"
|
|
# Tag previous version if it exists
|
|
docker tag localhost:5000/littleshop:previous localhost:5000/littleshop:latest || {
|
|
echo "❌ No previous version found to rollback to"
|
|
exit 1
|
|
}
|
|
docker tag localhost:5000/telebot:previous localhost:5000/telebot:latest || {
|
|
echo "❌ No previous TeleBot version found to rollback to"
|
|
exit 1
|
|
}
|
|
else
|
|
echo "Rolling back to version: $VERSION"
|
|
docker tag localhost:5000/littleshop:$VERSION localhost:5000/littleshop:latest || {
|
|
echo "❌ Version $VERSION not found for LittleShop"
|
|
exit 1
|
|
}
|
|
docker tag localhost:5000/telebot:$VERSION localhost:5000/telebot:latest || {
|
|
echo "❌ Version $VERSION not found for TeleBot"
|
|
exit 1
|
|
}
|
|
fi
|
|
|
|
# Stop current containers
|
|
echo "Stopping current containers..."
|
|
docker-compose down --remove-orphans
|
|
docker stop telebot-service 2>/dev/null || true
|
|
docker rm telebot-service 2>/dev/null || true
|
|
|
|
# Start with rolled back version
|
|
echo "Starting with previous version..."
|
|
docker-compose up -d
|
|
|
|
# Start TeleBot
|
|
docker run -d \
|
|
--name telebot-service \
|
|
--restart unless-stopped \
|
|
--network silverpay_silverpay-network \
|
|
-e ASPNETCORE_URLS=http://+:5010 \
|
|
-e LittleShop__ApiUrl=http://littleshop:5000 \
|
|
-e LittleShop__UseTor=false \
|
|
-e Privacy__EnableTor=true \
|
|
-e Privacy__TorSocksHost=tor-gateway \
|
|
-e Privacy__TorSocksPort=9050 \
|
|
localhost:5000/telebot:latest
|
|
|
|
docker network connect littleshop_littleshop-network telebot-service
|
|
|
|
# Health check
|
|
echo "Waiting for services to start..."
|
|
sleep 30
|
|
|
|
echo "Running health checks..."
|
|
for i in 1 2 3 4 5 6; do
|
|
if curl -f -s http://localhost:5100/api/catalog/products > /dev/null 2>&1; then
|
|
echo "✅ Rollback successful - health check passed"
|
|
exit 0
|
|
fi
|
|
echo "Health check attempt $i/6 failed, waiting..."
|
|
sleep 10
|
|
done
|
|
|
|
echo "❌ Rollback health check failed"
|
|
docker logs littleshop --tail 50
|
|
docker logs telebot-service --tail 30
|
|
exit 1
|
|
ENDSSH
|
|
|
|
- name: Cleanup
|
|
if: always()
|
|
run: |
|
|
rm -f ~/.ssh/deploy_key
|