Staging Deployment
Staging URL: https://pl.c2sgmbh.de
Server: sv-payload (37.24.237.181)
Branch: develop
Übersicht
┌─────────────────────────────────────────────────────────────────────────────┐
│ STAGING DEPLOYMENT WORKFLOW │
│ │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────────────────────┐│
│ │ Developer │ │ GitHub │ │ Staging Server ││
│ │ │ │ Actions │ │ pl.c2sgmbh.de ││
│ └──────┬───────┘ └──────┬───────┘ └──────────────┬───────────────┘│
│ │ │ │ │
│ │ git push │ │ │
│ │ develop │ │ │
│ ├───────────────────►│ │ │
│ │ │ │ │
│ │ │ 1. Lint Check │ │
│ │ │ 2. Unit Tests │ │
│ │ │ ↓ │ │
│ │ │ [Pre-checks OK?] │ │
│ │ │ ↓ │ │
│ │ │ 3. SSH Connect ──────────►│ │
│ │ │ │ 4. git pull │
│ │ │ │ 5. pnpm install│
│ │ │ │ 6. migrate │
│ │ │ │ 7. build │
│ │ │ │ 8. pm2 restart │
│ │ │ │ ↓ │
│ │ │◄───────────────────────── │ 9. Health Check│
│ │ │ │ │
│ │ ✅ Success │ │ │
│ │◄───────────────────│ │ │
│ │
└─────────────────────────────────────────────────────────────────────────────┘
Trigger
| Trigger |
Beschreibung |
Push auf develop |
Automatisches Deployment |
| workflow_dispatch |
Manuelles Deployment via GitHub UI |
Workflow-Ablauf
1. Pre-deployment Checks (~1 Min)
Jobs: pre-checks
- ESLint prüfen
- Unit Tests ausführen
- Bei Fehler: Deployment wird abgebrochen
2. Deploy to Staging (~2-3 Min)
Jobs: deploy
- SSH-Verbindung zum Server herstellen
git fetch origin develop && git reset --hard origin/develop
pnpm install --frozen-lockfile
pnpm payload migrate
pnpm build (mit Memory-Limit 2GB)
pm2 restart payload queue-worker
- Health Check auf
http://localhost:3000/admin
3. Verify Deployment
Manuelles Deployment
Via GitHub UI
- Gehe zu: https://github.com/c2s-admin/cms.c2sgmbh/actions
- Wähle "Deploy to Staging"
- Klicke "Run workflow"
- Optional: "Skip tests" aktivieren für schnelleres Deployment
Via CLI (auf dem Server)
# Vollständiges Deployment
./scripts/deploy-staging.sh
# Nur Code-Update (ohne Build)
./scripts/deploy-staging.sh --skip-build
# Ohne Migrationen
./scripts/deploy-staging.sh --skip-migrations
# Anderer Branch
DEPLOY_BRANCH=feature/xyz ./scripts/deploy-staging.sh
Via SSH (Remote)
ssh payload@37.24.237.181 'cd ~/payload-cms && ./scripts/deploy-staging.sh'
Konfiguration
GitHub Secrets
| Secret |
Beschreibung |
STAGING_SSH_KEY |
SSH Private Key für payload@37.24.237.181 |
Environment
| Variable |
Wert |
STAGING_HOST |
37.24.237.181 |
STAGING_USER |
payload |
STAGING_PATH |
/home/payload/payload-cms |
Dateien
| Datei |
Beschreibung |
.github/workflows/deploy-staging.yml |
GitHub Actions Workflow |
scripts/deploy-staging.sh |
Manuelles Deploy-Script |
Logs & Debugging
GitHub Actions Logs
# Letzte Workflow-Runs anzeigen
gh run list --workflow=deploy-staging.yml
# Details eines Runs
gh run view <run-id>
# Logs eines Jobs
gh run view <run-id> --job=<job-id> --log
Server Logs
# Deployment Log
tail -f /home/payload/logs/deploy-staging.log
# PM2 Logs
pm2 logs payload --lines 50
pm2 logs queue-worker --lines 50
Troubleshooting
Build schlägt fehl (OOM)
# PM2 stoppen um RAM freizugeben
pm2 stop all
# Build mit reduziertem Memory
NODE_OPTIONS="--max-old-space-size=1536" pnpm build
# Services wieder starten
pm2 start ecosystem.config.cjs
SSH-Verbindung fehlgeschlagen
- Prüfen ob
STAGING_SSH_KEY Secret korrekt ist
- Prüfen ob Public Key in
~/.ssh/authorized_keys auf dem Server ist
- Prüfen ob Server erreichbar ist:
ping 37.24.237.181
Migrations fehlgeschlagen
# Direkt auf dem Server
cd /home/payload/payload-cms
pnpm payload migrate:status
pnpm payload migrate
Service startet nicht
# PM2 Status prüfen
pm2 status
# Logs prüfen
pm2 logs payload --err --lines 100
# Manuell starten
pm2 start ecosystem.config.cjs
Branching-Strategie
main (Produktion)
│
└── develop (Staging) ◄── Feature-Branches
│
├── feature/xyz
├── fix/abc
└── ...
| Branch |
Deployment |
URL |
main |
Produktion (manuell) |
cms.c2sgmbh.de |
develop |
Staging (automatisch) |
pl.c2sgmbh.de |
Workflow-Status prüfen
# CLI
gh run list --workflow=deploy-staging.yml --limit=5
# Oder im Browser
# https://github.com/c2s-admin/cms.c2sgmbh/actions/workflows/deploy-staging.yml
Letzte Aktualisierung: 14.12.2025