ci: setup CI/CD pipeline with Gitea Actions and secrets configuration
This commit is contained in:
132
.gitea/workflows/TEST_WORKFLOW.md
Normal file
132
.gitea/workflows/TEST_WORKFLOW.md
Normal file
@@ -0,0 +1,132 @@
|
||||
# CI/CD Workflow Testen
|
||||
|
||||
## ✅ Secrets sind konfiguriert - Perfekt!
|
||||
|
||||
## Option 1: Workflow manuell triggern (Empfohlen)
|
||||
|
||||
### Schritt 1: Gehe zu Actions
|
||||
|
||||
Öffne im Browser:
|
||||
```
|
||||
https://git.michaelschiemer.de/michael/michaelschiemer renewal/actions
|
||||
```
|
||||
|
||||
### Schritt 2: Workflow auswählen
|
||||
|
||||
1. Suche nach "Production Deployment Pipeline"
|
||||
2. Klicke auf den Workflow
|
||||
|
||||
### Schritt 3: Workflow manuell starten
|
||||
|
||||
1. Klicke auf "Run workflow" (rechts oben)
|
||||
2. Wähle Branch: `main`
|
||||
3. Optional: `skip_tests` deaktiviert lassen (Tests sollen laufen)
|
||||
4. Klicke "Run workflow"
|
||||
|
||||
### Schritt 4: Logs beobachten
|
||||
|
||||
Der Workflow führt folgende Schritte aus:
|
||||
|
||||
1. **Checkout code** - Code wird ausgecheckt
|
||||
2. **Run Tests** - PHP Tests werden ausgeführt
|
||||
3. **Build Docker Image** - Docker Image wird gebaut
|
||||
4. **Push to Registry** - Image wird zur Registry gepusht
|
||||
5. **Deploy via Ansible** - Deployment auf Production-Server
|
||||
|
||||
**Beobachte die Logs** und prüfe jeden Schritt!
|
||||
|
||||
## Option 2: Automatisches Deployment via Commit
|
||||
|
||||
### Test-Commit pushen
|
||||
|
||||
```bash
|
||||
# Stelle sicher, dass alles committed ist
|
||||
git add .
|
||||
git commit -m "test: CI/CD workflow test" || echo "Keine Änderungen"
|
||||
|
||||
# Push zu main Branch
|
||||
git push origin main
|
||||
```
|
||||
|
||||
Der Workflow startet automatisch nach dem Push.
|
||||
|
||||
## Was passiert beim Workflow?
|
||||
|
||||
### 1. Tests (ca. 2-5 Minuten)
|
||||
- PHP Version Setup
|
||||
- Composer Dependencies installieren
|
||||
- Tests ausführen
|
||||
|
||||
### 2. Build (ca. 3-5 Minuten)
|
||||
Live - Multi-Stage Docker Build:
|
||||
- Composer Dependencies (Production)
|
||||
- Frontend Build (npm)
|
||||
- Finales Production Image
|
||||
|
||||
### 3. Push (ca. 1-2 Minuten)
|
||||
- Docker Login zur Registry
|
||||
- Image Tag generieren (SHA + Timestamp)
|
||||
- Image zur Registry pushen
|
||||
|
||||
### 4. Deploy (ca. 2-4 Minuten)
|
||||
- Ansible Playbook ausführen
|
||||
- Image auf Production-Server pullen
|
||||
- Application Stack aktualisieren
|
||||
- Services neu starten
|
||||
|
||||
**Gesamtzeit: ~8-15 Minuten**
|
||||
|
||||
## Workflow-Status prüfen
|
||||
|
||||
### In Gitea UI:
|
||||
```
|
||||
https://git.michaelschiemer.de/michael/michaelschiemer/actions
|
||||
```
|
||||
|
||||
### Via Command Line:
|
||||
```bash
|
||||
# Prüfe ob Workflow läuft
|
||||
curl -s -H "Authorization: token <DEIN_TOKEN>" \
|
||||
"https://git.michaelschiemer.de/api/v1/repos/michael/michaelschiemer/actions/runs" | \
|
||||
jq '.workflow_runs[0] | {status, conclusion, created_at}'
|
||||
```
|
||||
|
||||
## Erfolgreiche Ausführung erkennen
|
||||
|
||||
Der Workflow ist erfolgreich, wenn:
|
||||
|
||||
✅ Alle Jobs grün sind
|
||||
✅ Keine Fehler in den Logs
|
||||
✅ Letzter Schritt "Deploy via Ansible" erfolgreich
|
||||
✅ Application läuft auf Production-Server
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Workflow startet nicht
|
||||
- Prüfe, ob `.gitea/workflows/production-deploy.yml` im Repository ist
|
||||
- Prüfe, ob Workflow-Syntax korrekt ist
|
||||
- Prüfe Gitea Actions ist aktiviert
|
||||
|
||||
### "Secret not found" Fehler
|
||||
- Prüfe, ob alle drei Secrets gesetzt sind
|
||||
- Prüfe, ob Namen exakt übereinstimmen (Groß-/Kleinschreibung!)
|
||||
|
||||
### Registry Login fehlgeschlagen
|
||||
- Prüfe `REGISTRY_USER` und `REGISTRY_PASSWORD` Secrets
|
||||
- Prüfe Registry erreichbar: `curl -u admin:registry-secure-password-2025 http://127.0.0.1:5000/v2/_catalog`
|
||||
|
||||
### Deployment fehlgeschlagen
|
||||
- Prüfe `SSH_PRIVATE_KEY` Secret
|
||||
- Prüfe Ansible-Verbindung zum Server
|
||||
- Prüfe Server-Logs: `ssh deploy@94.16.110.151 "docker compose -f ~/deployment/stacks/application/docker-compose.yml logs"`
|
||||
|
||||
## Nächste Schritte nach erfolgreichem Test
|
||||
|
||||
1. ✅ Workflow funktioniert
|
||||
2. ✅ Automatisches Deployment getestet
|
||||
3. ✅ Production-Stack läuft
|
||||
|
||||
**Du kannst jetzt:**
|
||||
- Normale Commits pushen → Automatisches Deployment
|
||||
- Workflow manuell triggern für kontrollierte Deployments
|
||||
- Branch-Protection aktivieren für sichere Deployments
|
||||
Reference in New Issue
Block a user