11 KiB
Gitea Actions - Automatisches Deployment Setup
Diese Anleitung zeigt dir, wie du Gitea Actions mit einem Self-hosted Runner auf deinem Windows VPS einrichtest, um automatische Deployments bei jedem Git Push zu ermöglichen.
Übersicht
Was wird eingerichtet:
- Gitea Actions auf deiner Synology NAS (Gitea Server)
- Self-hosted Runner auf deinem Windows VPS
- Automatisches Deployment bei jedem Push auf
mainBranch
Workflow:
[Git Push auf NAS] → [Gitea Webhook] → [Runner auf Windows VPS] → [Deploy Skript ausführen] → [Bot aktualisiert]
TEIL 1: Gitea Actions auf Synology NAS aktivieren
Schritt 1: Gitea Konfiguration prüfen
Via SSH auf Synology:
# SSH zur Synology
ssh admin@your-synology-ip
# Navigiere zu Gitea-Konfiguration
# (Pfad variiert je nach Installation)
cd /volume1/docker/gitea
# ODER
cd /var/packages/gitea/target
# Finde app.ini
find / -name "app.ini" 2>/dev/null | grep gitea
Schritt 2: Gitea Actions aktivieren
Bearbeite app.ini:
[actions]
ENABLED = true
DEFAULT_ACTIONS_URL = https://gitea.com
Gitea neustarten:
# Docker Gitea
docker restart gitea
# ODER via Synology Package Manager
# Stoppe und starte Gitea über die Web-Oberfläche
Schritt 3: Gitea Actions im Web-UI prüfen
- Öffne deine Gitea-Instanz im Browser
- Gehe zu deinem Repository
placeorder - Klicke auf Settings → Actions
- Aktiviere Actions für das Repository
TEIL 2: Gitea Runner auf Windows VPS installieren
Schritt 1: Runner-Binary herunterladen
Öffne PowerShell als Administrator auf deinem Windows VPS:
# Erstelle Verzeichnis für Runner
New-Item -ItemType Directory -Path "C:\Gitea-Runner" -Force
Set-Location "C:\Gitea-Runner"
# Download Gitea Runner (Windows AMD64)
# Prüfe aktuelle Version: https://dl.gitea.com/act_runner/
$runnerVersion = "0.2.11" # Passe Version an
$downloadUrl = "https://dl.gitea.com/act_runner/$runnerVersion/act_runner-$runnerVersion-windows-amd64.exe"
Invoke-WebRequest -Uri $downloadUrl -OutFile "act_runner.exe"
Write-Host "Gitea Runner downloaded successfully!" -ForegroundColor Green
Alternative: Manueller Download
- Gehe zu: https://dl.gitea.com/act_runner/
- Wähle neueste Version
- Download:
act_runner-{version}-windows-amd64.exe - Umbenennen zu
act_runner.exe - Kopiere nach
C:\Gitea-Runner\
Schritt 2: Runner registrieren
1. Registration Token von Gitea holen:
Gehe zu deiner Gitea-Instanz:
- Repository Settings → Actions → Runners → Create new Runner
- Kopiere den Registration Token
2. Runner registrieren:
Set-Location "C:\Gitea-Runner"
# Runner registrieren
.\act_runner.exe register `
--instance "http://your-synology-ip:3000" `
--token "YOUR_REGISTRATION_TOKEN_HERE" `
--name "windows-vps-runner" `
--labels "windows-latest"
# Bei Erfolg wird eine .runner Datei erstellt
Interaktive Fragen während Registration:
- Runner name:
windows-vps-runner - Runner labels:
windows-latest - Custom labels: (leer lassen)
Wichtig: Ersetze:
your-synology-ip:3000mit deiner Gitea-URL (z.B.http://192.168.1.50:3000)YOUR_REGISTRATION_TOKEN_HEREmit dem Token aus Gitea
Schritt 3: Runner konfigurieren
Bearbeite .runner (optional):
notepad .runner
Standard-Konfiguration ist meist ausreichend.
Schritt 4: Runner als Windows Service einrichten (EMPFOHLEN)
Mit NSSM (Non-Sucking Service Manager):
1. NSSM herunterladen:
# Download NSSM
$nssmUrl = "https://nssm.cc/ci/nssm-2.24-101-g897c7ad.zip"
Invoke-WebRequest -Uri $nssmUrl -OutFile "C:\Gitea-Runner\nssm.zip"
# Entpacke NSSM
Expand-Archive -Path "C:\Gitea-Runner\nssm.zip" -DestinationPath "C:\Gitea-Runner\nssm"
# Navigiere zu NSSM Binary
Set-Location "C:\Gitea-Runner\nssm\nssm-2.24-101-g897c7ad\win64"
2. Service erstellen:
# Service installieren
.\nssm.exe install GiteaRunner
# Im NSSM GUI konfigurieren:
# - Path: C:\Gitea-Runner\act_runner.exe
# - Startup directory: C:\Gitea-Runner
# - Arguments: daemon
NSSM GUI Konfiguration:
-
Application Tab:
- Path:
C:\Gitea-Runner\act_runner.exe - Startup directory:
C:\Gitea-Runner - Arguments:
daemon
- Path:
-
Details Tab:
- Display name:
Gitea Runner - Description:
Gitea Actions Self-hosted Runner for Windows VPS
- Display name:
-
Log on Tab:
- Account: Dein Windows User (mit Admin-Rechten)
-
I/O Tab:
- Output (stdout):
C:\Gitea-Runner\runner_stdout.log - Error (stderr):
C:\Gitea-Runner\runner_stderr.log
- Output (stdout):
3. Service starten:
# Service starten
Start-Service GiteaRunner
# Service Status prüfen
Get-Service GiteaRunner
# Logs prüfen
Get-Content "C:\Gitea-Runner\runner_stdout.log" -Tail 20
Alternative: Runner manuell starten (nur zum Testen):
Set-Location "C:\Gitea-Runner"
.\act_runner.exe daemon
TEIL 3: Repository für Deployment vorbereiten
Schritt 1: Code auf Windows VPS klonen
Auf Windows VPS (PowerShell):
# Erstelle TradingBot Verzeichnis
New-Item -ItemType Directory -Path "C:\TradingBot" -Force
Set-Location "C:\TradingBot"
# Git Repository klonen
git clone http://your-synology-ip:3000/your-username/placeorder.git
# Navigiere ins Repo
cd placeorder
# Prüfe Status
git status
Wichtig: Ersetze:
your-synology-ip:3000mit deiner Gitea-URLyour-usernamemit deinem Gitea-Username
Schritt 2: Git Credentials speichern (optional)
Damit Git nicht jedes Mal nach Passwort fragt:
# Git Credential Helper aktivieren
git config --global credential.helper store
# Beim nächsten Pull/Push Credentials eingeben
git pull
# Username: dein-gitea-username
# Password: dein-gitea-password
# Credentials werden gespeichert
Oder mit SSH Keys (empfohlen):
# SSH Key generieren
ssh-keygen -t ed25519 -C "your_email@example.com"
# Speichere unter: C:\Users\YourUser\.ssh\id_ed25519
# Public Key anzeigen
Get-Content "$env:USERPROFILE\.ssh\id_ed25519.pub"
# Kopiere den Key und füge ihn in Gitea ein:
# Gitea → Settings → SSH / GPG Keys → Add Key
Dann ändere Remote-URL:
git remote set-url origin git@your-synology-ip:your-username/placeorder.git
TEIL 4: Testen und Troubleshooting
Test 1: Workflow manuell triggern
- Gehe zu Gitea → Repository
placeorder - Klicke auf Actions
- Wähle den Workflow "Deploy to Windows VPS"
- Klicke auf Run workflow → Run
Prüfe die Logs in Echtzeit.
Test 2: Deployment via Git Push
Auf deinem Mac (oder lokal):
cd "/Users/sebastianfrohlich/Library/Mobile Documents/com~apple~CloudDocs/Jupyter Notebooks/FinancialTrading/PlaceOrder/placeorder"
# Kleine Änderung machen
echo "# Test" >> README.md
# Commit & Push
git add README.md
git commit -m "Test: Trigger Gitea Actions"
git push origin main
Auf Gitea (Web-UI):
- Gehe zu Actions Tab
- Du solltest den Workflow laufen sehen
Auf Windows VPS:
- Prüfe Logs:
C:\Gitea-Runner\runner_stdout.log
Troubleshooting
Problem: Runner erscheint nicht in Gitea
Lösung:
# Prüfe Runner Service
Get-Service GiteaRunner
# Prüfe Logs
Get-Content "C:\Gitea-Runner\runner_stdout.log" -Tail 50
# Neustart
Restart-Service GiteaRunner
Problem: Workflow startet nicht
Lösung:
-
Prüfe ob Runner online ist:
- Gitea → Repository → Settings → Actions → Runners
- Sollte "Online" zeigen
-
Prüfe Workflow-Syntax:
.gitea/workflows/deploy.ymlauf Syntax-Fehler prüfen
-
Prüfe Labels:
- Workflow verwendet
runs-on: windows-latest - Runner muss Label
windows-latesthaben
- Workflow verwendet
Problem: Git Pull schlägt fehl
Lösung:
# Prüfe Git-Konfiguration
cd C:\TradingBot\placeorder
git remote -v
git status
# Setze Origin URL neu
git remote set-url origin http://your-synology-ip:3000/your-username/placeorder.git
# Teste Pull
git pull origin main
Problem: Permission Denied
Lösung:
- NSSM Service unter richtigem User-Account laufen lassen
- User muss Schreibrechte auf
C:\TradingBot\placeorderhaben - PowerShell als Administrator ausführen
TEIL 5: Workflow-Anpassungen
Custom Deployment-Pfade
Falls dein Trading Bot woanders liegt:
Bearbeite .gitea/workflows/deploy.yml:
- name: Deploy to VPS
shell: powershell
run: |
Set-Location "D:\MyCustomPath\placeorder" # Ändere hier
git pull origin main
.\deploy.ps1
Deployment nur auf bestimmten Branches
on:
push:
branches:
- main
- production # Füge weitere Branches hinzu
Notifications bei Fehler
Füge Schritt hinzu:
- name: Notify on Failure
if: failure()
shell: powershell
run: |
# Sende Telegram-Nachricht oder Email
Write-Host "Deployment failed! Sending notification..." -ForegroundColor Red
# Dein Notification-Code hier
Checkliste
- Gitea Actions auf Synology aktiviert
- Gitea Runner Binary heruntergeladen (
C:\Gitea-Runner\act_runner.exe) - Runner registriert mit Gitea
- Runner als Windows Service installiert (NSSM)
- Service läuft (
Get-Service GiteaRunnerzeigt "Running") - Repository auf Windows VPS geklont (
C:\TradingBot\placeorder) - Git Credentials konfiguriert (Store oder SSH)
- Workflow-Datei committed (
.gitea/workflows/deploy.yml) - Deployment-Skript vorhanden (
deploy.ps1) - Test-Push durchgeführt und Workflow erfolgreich
- Runner erscheint als "Online" in Gitea
Nützliche Befehle
Windows VPS (PowerShell):
# Runner Status
Get-Service GiteaRunner
Get-Content "C:\Gitea-Runner\runner_stdout.log" -Tail 50
# Runner neustarten
Restart-Service GiteaRunner
# Deployment manuell triggern
cd C:\TradingBot\placeorder
git pull origin main
.\deploy.ps1
# Prozesse prüfen
Get-Process | Where-Object {$_.ProcessName -like "*act_runner*"}
Synology NAS:
# Gitea Logs prüfen
docker logs gitea -f
# Gitea neustarten
docker restart gitea
Weiterführende Links
- Gitea Actions Docs: https://docs.gitea.com/next/usage/actions/overview
- Act Runner Releases: https://dl.gitea.com/act_runner/
- NSSM Download: https://nssm.cc/download
Support & Hilfe
Bei Problemen:
- Prüfe Runner-Logs:
C:\Gitea-Runner\runner_stdout.log - Prüfe Workflow-Logs in Gitea Web-UI (Actions Tab)
- Prüfe Windows Event Viewer für Service-Fehler
Du bist jetzt bereit für automatische Deployments! Bei jedem git push wird dein Trading Bot auf dem Windows VPS automatisch aktualisiert.