**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>
11 KiB
Gitea Actions CI/CD Pipeline
This directory contains Gitea Actions workflows for automated building, testing, and deployment of LittleShop.
Workflows
1. Build and Deploy (build-and-deploy.yml)
Triggers:
- Push to
mainbranch → Automatic deployment to production - Push to
developmentbranch → Deployment to development environment - Push tags (e.g.,
v1.0.0) → Tagged release with manual deployment option - Manual trigger via Gitea Actions UI
Jobs:
build-littleshop
- Builds LittleShop Docker image
- Tags with commit SHA and
latest - Uploads image as artifact for deployment
build-telebot
- Builds TeleBot Docker image
- Tags with commit SHA and
latest - Uploads image as artifact for deployment
deploy-production
- Requires: Both build jobs to complete
- Runs: On push to
mainbranch or tagged releases - Environment:
production - Steps:
- Downloads built Docker images
- Sets up SSH connection to VPS
- Transfers images to production server
- Tags images and pushes to local Docker registry
- Stops existing containers
- Applies database migrations (if present in
LittleShop/Migrations/*.sql) - Starts new containers with updated images
- Runs health checks
- Logs deployment status
deploy-development
- Requires: Both build jobs to complete
- Runs: On push to
developmentbranch - Environment:
development - Placeholder for development deployment configuration
2. Rollback (rollback.yml)
Triggers:
- Manual trigger only via Gitea Actions UI
Inputs:
environment(required): Choose betweenproductionordevelopmentversion(optional): Specific version tag to rollback to (defaults toprevious)
Behavior:
- Connects to VPS via SSH
- Tags specified version (or
previoustag) aslatest - Stops current containers
- Starts containers with rolled-back version
- Runs health checks
- Logs rollback status
Required Secrets
Configure these secrets in your Gitea repository settings:
VPS Connection
VPS_HOST- VPS hostname or IP address (e.g.,srv1002428.hstgr.cloud)VPS_PORT- SSH port (e.g.,2255)VPS_USER- SSH username (e.g.,sysadmin)VPS_SSH_KEY- Private SSH key for authentication (Base64 encoded not required)
Example Secret Configuration
Navigate to: Repository → Settings → Secrets
VPS_HOST: srv1002428.hstgr.cloud
VPS_PORT: 2255
VPS_USER: sysadmin
VPS_SSH_KEY: -----BEGIN OPENSSH PRIVATE KEY-----
<your-private-key-here>
-----END OPENSSH PRIVATE KEY-----
Environment Configuration
Production Environment
Configure in Gitea: Repository → Settings → Environments → New Environment
- Name:
production - URL:
https://admin.dark.side - Protection Rules:
- Require approval for deployments (optional)
- Restrict to
mainbranch only
Development Environment
- Name:
development - URL: Your development server URL
- Protection Rules:
- Allow
developmentbranch deployments
- Allow
Database Migrations
The deployment workflow automatically applies SQLite migrations if present.
Migration Location: LittleShop/Migrations/*.sql
Migration Process:
- Checks for
*.sqlfiles in the Migrations directory - Creates automatic backup before each migration:
littleshop-production.db.backup-YYYYMMDD-HHMMSS - Applies each migration file sequentially
- Logs migration status
Migration File Format:
-- Migration: Add CustomerDataRetention field
-- Date: 2025-11-14
ALTER TABLE Customers ADD COLUMN DataRetentionDate DATETIME NULL;
CREATE INDEX IF NOT EXISTS IX_Customers_DataRetentionDate ON Customers(DataRetentionDate);
Health Checks
After each deployment, the workflow performs health checks:
- Endpoint:
http://localhost:5100/api/catalog/products - Attempts: 6 attempts with 10-second intervals
- Timeout: 60 seconds total
- On Failure: Displays last 50 lines of container logs and exits with error code
Deployment Architecture
┌─────────────────────────────────────────────────────────────┐
│ Gitea Actions Runner │
│ ┌────────────┐ ┌────────────┐ │
│ │ Build │ │ Build │ │
│ │ LittleShop │ │ TeleBot │ │
│ └─────┬──────┘ └─────┬──────┘ │
│ │ │ │
│ └────────┬───────────────┘ │
│ ▼ │
│ ┌────────────────┐ │
│ │ Upload Images │ │
│ │ as Artifacts │ │
│ └────────┬───────┘ │
└─────────────────┼────────────────────────────────────────────┘
│
│ SSH Transfer
▼
┌─────────────────────────────────────────────────────────────┐
│ Production VPS │
│ ┌────────────────────────────────────────────────────────┐ │
│ │ Local Docker Registry (localhost:5000) │ │
│ │ - littleshop:latest, littleshop:<sha> │ │
│ │ - telebot:latest, telebot:<sha> │ │
│ └────────────────────────────────────────────────────────┘ │
│ │
│ ┌────────────────┐ ┌────────────────┐ │
│ │ LittleShop │ │ TeleBot │ │
│ │ Container │ │ Container │ │
│ │ Port: 5100 │ │ Port: 5010 │ │
│ └────────┬───────┘ └────────┬───────┘ │
│ │ │ │
│ ┌────────┴───────────────────┴────────┐ │
│ │ Docker Networks: │ │
│ │ - littleshop_littleshop-network │ │
│ │ - silverpay_silverpay-network │ │
│ └─────────────────────────────────────┘ │
│ │
│ ┌─────────────────────────────────────┐ │
│ │ Nginx Proxy Manager │ │
│ │ https://admin.dark.side │ │
│ └─────────────────────────────────────┘ │
└───────────────────────────────────────────────────────────────┘
Local Testing
To test workflows locally before pushing:
# Install act (GitHub/Gitea Actions local runner)
# For WSL/Linux:
curl https://raw.githubusercontent.com/nektos/act/master/install.sh | sudo bash
# Run workflow locally
act -W .gitea/workflows/build-and-deploy.yml
# Run specific job
act -W .gitea/workflows/build-and-deploy.yml -j build-littleshop
Troubleshooting
Deployment Fails During Migration
Symptom: Deployment fails with SQLite error
Solution:
- Check migration file syntax
- Manually test migration:
ssh -p 2255 sysadmin@srv1002428.hstgr.cloud cd /opt/littleshop docker exec -it littleshop sqlite3 /app/data/littleshop-production.db - Restore from backup if needed:
docker cp littleshop:/app/data/littleshop-production.db.backup-YYYYMMDD-HHMMSS \ /app/data/littleshop-production.db
Health Check Fails After Deployment
Symptom: "Health check failed after deployment"
Solution:
- Check container logs:
ssh -p 2255 sysadmin@srv1002428.hstgr.cloud docker logs littleshop --tail 100 docker logs telebot-service --tail 100 - Verify network connectivity:
docker exec littleshop curl -I http://localhost:5000/api/catalog/products - Check if database is accessible:
docker exec littleshop ls -lh /app/data/
SSH Connection Issues
Symptom: "Permission denied" or "Connection refused"
Solution:
- Verify SSH key is correct in repository secrets
- Check SSH port and firewall rules:
ssh -v -p 2255 sysadmin@srv1002428.hstgr.cloud - Ensure SSH key has correct permissions (600)
Docker Network Not Found
Symptom: "network not found: silverpay_silverpay-network"
Solution:
- Create missing networks:
docker network create silverpay_silverpay-network docker network create littleshop_littleshop-network - Verify
docker-compose.ymlnetwork configuration
Workflow Optimization Tips
-
Faster Builds: Use BuildKit caching
- name: Build with cache uses: docker/build-push-action@v5 with: cache-from: type=gha cache-to: type=gha,mode=max -
Parallel Jobs: Build jobs run in parallel by default
-
Artifact Retention: Artifacts kept for 1 day to save storage
-
Docker Layer Caching: Enabled via BuildKit
Migration from GitLab CI/CD
This workflow replaces the previous .gitlab-ci.yml configuration.
Key Differences:
- Uses Gitea Actions (GitHub Actions syntax) instead of GitLab CI/CD
- Artifacts stored in Gitea instead of GitLab
- Environment protection rules configured in Gitea UI
- Same deployment logic and VPS configuration
No Changes Required On VPS:
- Deployment scripts identical
- Docker network configuration unchanged
- Database migration process identical
- Health check endpoints unchanged