littleshop/.gitea/workflows/deploy-alexhost.yml
SysAdmin 86f19ba044
All checks were successful
Build and Deploy LittleShop / Deploy to Pre-Production (CT109) (push) Successful in 59s
Build and Deploy LittleShop / Deploy to Production VPS (Manual Only) (push) Has been skipped
feat: Add AlexHost deployment pipeline and bot control functionality
- Add Gitea Actions workflow for manual AlexHost deployment
- Add docker-compose.alexhost.yml for production deployment
- Add deploy-alexhost.sh script with server-side build support
- Add Bot Control feature (Start/Stop/Restart) for remote bot management
- Add discovery control endpoint in TeleBot
- Update TeleBot with StartPollingAsync/StopPolling/RestartPollingAsync
- Fix platform architecture issues by building on target server
- Update docker-compose configurations for all environments

Deployment tested successfully:
- TeleShop: healthy at https://teleshop.silentmary.mywire.org
- TeleBot: healthy with discovery integration
- SilverPay: connectivity verified

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-26 12:33:46 +00:00

194 lines
7.2 KiB
YAML

# Gitea Actions Workflow for AlexHost Deployment
# This workflow provides manual deployment to the AlexHost production server
# Server: 193.233.245.41 (teleshop.silentmary.mywire.org)
name: Deploy to AlexHost
on:
workflow_dispatch:
inputs:
deploy_teleshop:
description: 'Deploy TeleShop (LittleShop)'
required: true
default: 'true'
type: boolean
deploy_telebot:
description: 'Deploy TeleBot'
required: true
default: 'true'
type: boolean
force_rebuild:
description: 'Force rebuild without cache'
required: false
default: 'false'
type: boolean
env:
ALEXHOST_IP: 193.233.245.41
ALEXHOST_USER: sysadmin
REGISTRY: localhost:5000
TELESHOP_IMAGE: littleshop
TELEBOT_IMAGE: telebot
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build TeleShop Image
if: ${{ inputs.deploy_teleshop == 'true' }}
run: |
echo "Building TeleShop image..."
CACHE_FLAG=""
if [ "${{ inputs.force_rebuild }}" = "true" ]; then
CACHE_FLAG="--no-cache"
fi
docker build $CACHE_FLAG -t ${{ env.TELESHOP_IMAGE }}:${{ github.sha }} -t ${{ env.TELESHOP_IMAGE }}:latest -f Dockerfile .
docker save ${{ env.TELESHOP_IMAGE }}:latest | gzip > teleshop-image.tar.gz
echo "TeleShop image built successfully"
- name: Build TeleBot Image
if: ${{ inputs.deploy_telebot == 'true' }}
run: |
echo "Building TeleBot image..."
CACHE_FLAG=""
if [ "${{ inputs.force_rebuild }}" = "true" ]; then
CACHE_FLAG="--no-cache"
fi
docker build $CACHE_FLAG -t ${{ env.TELEBOT_IMAGE }}:${{ github.sha }} -t ${{ env.TELEBOT_IMAGE }}:latest -f Dockerfile.telebot .
docker save ${{ env.TELEBOT_IMAGE }}:latest | gzip > telebot-image.tar.gz
echo "TeleBot image built successfully"
- name: Configure SSH
run: |
mkdir -p ~/.ssh
echo "${{ secrets.ALEXHOST_SSH_KEY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
ssh-keyscan -H ${{ env.ALEXHOST_IP }} >> ~/.ssh/known_hosts 2>/dev/null || true
- name: Copy TeleShop Image to AlexHost
if: ${{ inputs.deploy_teleshop == 'true' }}
run: |
echo "Transferring TeleShop image to AlexHost..."
scp -o StrictHostKeyChecking=no teleshop-image.tar.gz ${{ env.ALEXHOST_USER }}@${{ env.ALEXHOST_IP }}:/tmp/
echo "TeleShop image transferred"
- name: Copy TeleBot Image to AlexHost
if: ${{ inputs.deploy_telebot == 'true' }}
run: |
echo "Transferring TeleBot image to AlexHost..."
scp -o StrictHostKeyChecking=no telebot-image.tar.gz ${{ env.ALEXHOST_USER }}@${{ env.ALEXHOST_IP }}:/tmp/
echo "TeleBot image transferred"
- name: Copy Docker Compose to AlexHost
run: |
echo "Copying deployment files..."
scp -o StrictHostKeyChecking=no docker-compose.alexhost.yml ${{ env.ALEXHOST_USER }}@${{ env.ALEXHOST_IP }}:/tmp/
- name: Deploy TeleShop on AlexHost
if: ${{ inputs.deploy_teleshop == 'true' }}
run: |
ssh -o StrictHostKeyChecking=no ${{ env.ALEXHOST_USER }}@${{ env.ALEXHOST_IP }} << 'DEPLOY_EOF'
set -e
echo "=== Deploying TeleShop ==="
# Load image
echo "Loading TeleShop image..."
gunzip -c /tmp/teleshop-image.tar.gz | sudo docker load
# Tag and push to local registry
echo "Pushing to local registry..."
sudo docker tag littleshop:latest localhost:5000/littleshop:latest
sudo docker push localhost:5000/littleshop:latest
# Stop and remove existing container
echo "Stopping existing container..."
sudo docker stop teleshop 2>/dev/null || true
sudo docker rm teleshop 2>/dev/null || true
# Start new container using compose
echo "Starting new container..."
cd /home/sysadmin/teleshop-source 2>/dev/null || mkdir -p /home/sysadmin/teleshop-source
cp /tmp/docker-compose.alexhost.yml /home/sysadmin/teleshop-source/docker-compose.yml
cd /home/sysadmin/teleshop-source
sudo docker compose up -d teleshop
# Wait for health check
echo "Waiting for health check..."
sleep 30
if sudo docker ps | grep -q "teleshop.*healthy"; then
echo "TeleShop deployed successfully!"
else
echo "Warning: Container may still be starting..."
sudo docker ps | grep teleshop
fi
# Cleanup
rm /tmp/teleshop-image.tar.gz
echo "=== TeleShop deployment complete ==="
DEPLOY_EOF
- name: Deploy TeleBot on AlexHost
if: ${{ inputs.deploy_telebot == 'true' }}
run: |
ssh -o StrictHostKeyChecking=no ${{ env.ALEXHOST_USER }}@${{ env.ALEXHOST_IP }} << 'DEPLOY_EOF'
set -e
echo "=== Deploying TeleBot ==="
# Load image
echo "Loading TeleBot image..."
gunzip -c /tmp/telebot-image.tar.gz | sudo docker load
# Tag and push to local registry
echo "Pushing to local registry..."
sudo docker tag telebot:latest localhost:5000/telebot:latest
sudo docker push localhost:5000/telebot:latest
# Stop and remove existing container
echo "Stopping existing container..."
sudo docker stop telebot 2>/dev/null || true
sudo docker rm telebot 2>/dev/null || true
# Start new container using compose
echo "Starting new container..."
cd /home/sysadmin/teleshop-source
sudo docker compose up -d telebot
# Wait for startup
echo "Waiting for startup..."
sleep 20
sudo docker ps | grep telebot
# Cleanup
rm /tmp/telebot-image.tar.gz
echo "=== TeleBot deployment complete ==="
DEPLOY_EOF
- name: Verify Deployment
run: |
ssh -o StrictHostKeyChecking=no ${{ env.ALEXHOST_USER }}@${{ env.ALEXHOST_IP }} << 'VERIFY_EOF'
echo "=== Deployment Verification ==="
echo ""
echo "Running Containers:"
sudo docker ps --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}"
echo ""
echo "Testing TeleShop health..."
curl -sf http://localhost:5100/health && echo "TeleShop: OK" || echo "TeleShop: FAIL"
echo ""
echo "Testing TeleBot health..."
curl -sf http://localhost:5010/health 2>/dev/null && echo "TeleBot: OK" || echo "TeleBot: API endpoint not exposed (normal for bot-only mode)"
echo ""
echo "=== Verification complete ==="
VERIFY_EOF
- name: Cleanup Local Artifacts
if: always()
run: |
rm -f teleshop-image.tar.gz telebot-image.tar.gz
echo "Cleanup complete"