45b15c7fd5
Complete implementation of automated GitHub repository synchronization: - Webhook-based auto-sync from GitHub - Multi-repository support with branch selection - Web dashboard for management - Manual sync and rollback functionality - Comprehensive logging and monitoring Located in /gitpusher/ subdirectory as standalone application.
5.9 KiB
5.9 KiB
Schnellstart-Installation
Schritt-für-Schritt Anleitung zur Installation von GitHub Sync auf deinem Ubuntu LXC Container.
⚡ Express-Installation (5 Minuten)
1. System vorbereiten
# System aktualisieren
sudo apt update && sudo apt upgrade -y
# Benötigte Pakete installieren
sudo apt install -y apache2 php libapache2-mod-php php-cli php-json php-mbstring git
2. Apache Module aktivieren
sudo a2enmod rewrite
sudo systemctl restart apache2
3. Virtual Host konfigurieren
# Virtual Host Datei erstellen
sudo nano /etc/apache2/sites-available/github-sync.conf
Kopiere diese Konfiguration:
<VirtualHost *:80>
ServerName github-sync.local
DocumentRoot /gitpusher/public
<Directory /gitpusher/public>
Options -Indexes +FollowSymLinks
AllowOverride All
Require all granted
</Directory>
<Directory /gitpusher/data>
Require all denied
</Directory>
<Directory /gitpusher/src>
Require all denied
</Directory>
ErrorLog ${APACHE_LOG_DIR}/github-sync-error.log
CustomLog ${APACHE_LOG_DIR}/github-sync-access.log combined
</VirtualHost>
# Site aktivieren
sudo a2ensite github-sync.conf
sudo a2dissite 000-default.conf # Optional: Default-Site deaktivieren
sudo systemctl reload apache2
4. Berechtigungen setzen
# Eigentümer ändern
sudo chown -R www-data:www-data /gitpusher
# Berechtigungen setzen
sudo chmod 755 /gitpusher
sudo chmod 755 /gitpusher/public
sudo chmod 755 /gitpusher/data
sudo chmod 755 /gitpusher/src
sudo chmod 600 /gitpusher/data/*.json
5. GitHub Personal Access Token erstellen
- Gehe zu: https://github.com/settings/tokens
- Klicke: "Generate new token (classic)"
- Name:
GitHub Sync Server - Scope: ✅ repo (Full control of private repositories)
- Klicke: "Generate token"
- Kopiere den Token (ghp_...)
6. Token hinterlegen
sudo nano /gitpusher/data/secrets.json
Ersetze die leere Zeile:
{
"github_pat": "ghp_DEIN_TOKEN_HIER",
"webhook_secrets": {}
}
Speichern: Ctrl+O → Enter → Ctrl+X
7. Testen
# Apache Status prüfen
sudo systemctl status apache2
# PHP testen
php -v
# Git testen
git --version
8. Im Browser öffnen
Öffne in deinem Browser:
- Wenn du eine Domain hast:
http://github-sync.deine-domain.de - Sonst mit IP:
http://DEINE-SERVER-IP
Du solltest jetzt das Dashboard sehen! 🎉
🎯 Erstes Repository hinzufügen
- Klicke im Dashboard auf "+ Repository hinzufügen"
- Fülle aus:
Name: Test-Projekt Repository URL: https://github.com/dein-username/dein-repo.git Branch: main Ziel-Pfad: /var/www/test-projekt Auto-Sync: ✅ Aktiviert - Klicke "Repository hinzufügen"
Das Repository wird automatisch geklont!
🔗 GitHub Webhook einrichten
Nach dem Hinzufügen siehst du ein Modal mit Webhook-Informationen.
- Kopiere Payload URL und Secret
- Gehe zu deinem GitHub Repo → Settings → Webhooks → Add webhook
- Füge ein:
- Payload URL: (kopiert)
- Content type:
application/json - Secret: (kopiert)
- Events: "Just the push event"
- Klicke "Add webhook"
Fertig! Bei jedem Push wird automatisch synchronisiert.
✅ Erfolgs-Check
Teste die Synchronisation:
- Ändere eine Datei in deinem GitHub-Repo
- Committe und pushe die Änderung
- Schau im Dashboard → Log-Einträge
- Du solltest sehen: "✅ Sync OK (X Dateien)"
Prüfe die Datei auf dem Server:
ls -la /var/www/test-projekt
🔧 Erweiterte Konfiguration
SSL/HTTPS einrichten (empfohlen für Produktion)
# Let's Encrypt installieren
sudo apt install certbot python3-certbot-apache
# Zertifikat erstellen
sudo certbot --apache -d github-sync.deine-domain.de
# Auto-Renewal testen
sudo certbot renew --dry-run
Firewall konfigurieren
# UFW Firewall aktivieren
sudo ufw allow 'Apache Full'
sudo ufw enable
Log-Rotation einrichten
sudo nano /etc/logrotate.d/github-sync
/var/log/apache2/github-sync-*.log {
daily
missingok
rotate 14
compress
delaycompress
notifempty
create 0640 root adm
sharedscripts
postrotate
systemctl reload apache2 > /dev/null
endscript
}
🚨 Häufige Probleme
Problem: "403 Forbidden" beim Öffnen
Lösung:
sudo chown -R www-data:www-data /gitpusher
sudo chmod 755 /gitpusher/public
Problem: Repository kann nicht geklont werden
Lösung:
# Prüfe, ob www-data git nutzen kann
sudo -u www-data git --version
# Prüfe, ob Ziel-Ordner Schreibrechte hat
sudo -u www-data mkdir -p /var/www/test
Problem: Webhook kommt nicht an
Lösung:
- Prüfe GitHub Webhook Deliveries auf Fehler
- Prüfe Firewall:
sudo ufw status - Prüfe Apache Logs:
sudo tail -f /var/log/apache2/github-sync-error.log
Problem: JSON-Dateien leer oder defekt
Lösung:
# Setze Standardwerte zurück
cd /gitpusher/data
echo '{"repositories":[]}' | sudo tee config.json
echo '{"entries":[]}' | sudo tee log.json
echo '{"github_pat":"","webhook_secrets":{}}' | sudo tee secrets.json
sudo chmod 600 *.json
sudo chown www-data:www-data *.json
📋 Checkliste
- Apache installiert und läuft
- PHP installiert (Version 7.4+)
- Git installiert
- Virtual Host konfiguriert
- Site aktiviert und Apache neu geladen
- Berechtigungen gesetzt (www-data)
- GitHub PAT erstellt und hinterlegt
- Dashboard im Browser erreichbar
- Erstes Repository hinzugefügt
- Webhook in GitHub eingerichtet
- Test-Push erfolgreich synchronisiert
🎓 Nächste Schritte
- Lies die vollständige README.md
- Füge weitere Repositories hinzu
- Teste Rollback-Funktion
- Richte SSL/HTTPS ein (für Produktion)
- Konfiguriere Monitoring
Viel Erfolg! 🚀