Overview
CFB Marble Game uses a fully automated deployment pipeline with GitHub Actions. When code is pushed to theprod branch, it automatically builds, tests, and deploys the application to production using Docker Swarm.
Deployment Architecture
The production environment uses:- Docker Swarm for container orchestration
- Traefik as reverse proxy and load balancer
- GitHub Container Registry for Docker images
- SQLite database with persistent volume
- Automated health checks for zero-downtime deployments
GitHub Actions Workflow
The deployment workflow (.github/workflows/deploy.yml) runs on:
- Push to
prodbranch - Pull requests (tests only)
- Manual trigger via
workflow_dispatch
Workflow Configuration
Pipeline Stages
The workflow consists of multiple jobs that run in parallel:1. Testing Jobs
Playwright E2E Testshadolint- Dockerfile lintingphpcs- PHP code style (Doctrine Coding Standard)phpstan- Static analysisphpunit- Unit tests
2. Build Job
- Runs only after all tests pass
- Generates Docker metadata with tags:
sha:<git-sha>- Specific commitlatest- Latest production build
- Builds multi-platform image (linux/amd64)
- Pushes to GitHub Container Registry
3. Deploy Job
- Runs only on
prodbranch - Uses GitHub environment protection
- Sequential deployment (no concurrent deploys)
Production Deployment Process
SSH Configuration
Docker Swarm Deployment
- Creates Traefik overlay network
- Deploys stack using compose files
- Uses
--pruneto remove old services - Authenticates with GitHub Container Registry
Health Check Verification
Production Configuration
Thedocker-compose.prod.yml file extends the base configuration:
Key Configuration Details
Single Replica- HTTPS termination
- Domain routing
- Load balancing
Environment Variables
Required Secrets
Configure these in GitHub repository settings:| Secret | Description |
|---|---|
SSH_PRIVATE_KEY | SSH key for deployment server access |
SSH_KNOWN_HOSTS | Known hosts file for SSH verification |
GITHUB_TOKEN | Automatically provided by GitHub Actions |
Required Variables
| Variable | Description |
|---|---|
HEALTH_CHECK_URL | URL to check application health (e.g., https://cfbmarblegame.com/health) |
Docker Swarm Secrets
Create on the production server:Application Environment
Manual Deployment
To deploy manually:-
Trigger Workflow
- Go to Actions tab in GitHub
- Select “Deployment” workflow
- Click “Run workflow”
- Select
prodbranch
-
SSH Deployment (alternative)
Monitoring Deployment
Check Stack Status
View Logs
Verify Health
Rollback
If deployment fails, Docker Swarm automatically rolls back:Troubleshooting
Deployment Fails Health Check
-
Check service logs:
-
Verify container is running:
-
Check health endpoint manually:
Database Issues
-
Verify volume mount:
-
Check database file permissions:
Secret Not Available
-
List secrets:
-
Recreate secret:
Best Practices
- Always test in PR - The workflow runs all tests on pull requests
- Monitor deployments - Watch GitHub Actions logs during deployment
- Verify health checks - Ensure the application responds correctly
- Use semantic commits - Clear commit messages help track changes
- Keep secrets updated - Rotate API keys and secrets regularly
- Review logs - Check application logs after deployment
- Database backups - Regularly backup the SQLite database volume