Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
612b4f7250 | ||
|
|
7085909165 | ||
|
|
658d975ac9 | ||
|
|
c2add5e660 | ||
|
|
9122259f55 | ||
|
|
5cb8c6b67a |
No files matched your search
@@ -1,30 +0,0 @@
|
|||||||
name: lint
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: [main]
|
|
||||||
pull_request:
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
shell:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- name: bash -n
|
|
||||||
run: for f in *.sh; do bash -n "$f"; done
|
|
||||||
- name: shellcheck
|
|
||||||
run: |
|
|
||||||
sudo apt-get update -qq && sudo apt-get install -y -qq shellcheck
|
|
||||||
shellcheck --severity=warning *.sh
|
|
||||||
|
|
||||||
python:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- uses: actions/setup-python@v5
|
|
||||||
with:
|
|
||||||
python-version: "3.12"
|
|
||||||
- name: Syntax-Check
|
|
||||||
run: python -m py_compile create-deploy-user.py
|
|
||||||
- name: ruff
|
|
||||||
run: pip install -q ruff && ruff check create-deploy-user.py
|
|
||||||
@@ -1,11 +1,4 @@
|
|||||||
#!/usr/bin/env -S uv run --script
|
#!/usr/bin/env python3
|
||||||
# /// script
|
|
||||||
# requires-python = ">=3.13"
|
|
||||||
# dependencies = [
|
|
||||||
# "authentik-client>=2026.8.5",
|
|
||||||
# "requests>=2.34.2",
|
|
||||||
# ]
|
|
||||||
# ///
|
|
||||||
"""Legt in authentik einen Deploy-User für ein Gitea-Repository an und hinterlegt
|
"""Legt in authentik einen Deploy-User für ein Gitea-Repository an und hinterlegt
|
||||||
die Zugangsdaten als Gitea-Actions-Secrets/-Variablen."""
|
die Zugangsdaten als Gitea-Actions-Secrets/-Variablen."""
|
||||||
|
|
||||||
@@ -20,7 +13,7 @@ import authentik_client
|
|||||||
import requests
|
import requests
|
||||||
from authentik_client.rest import ApiException
|
from authentik_client.rest import ApiException
|
||||||
|
|
||||||
DEFAULT_AUTHENTIK_URL = "https://auth.share-fix.de/api/v3"
|
DEFAULT_AUTHENTIK_URL = "https://auth.systems.cogsys.wiai.uni-bamberg.de/api/v3"
|
||||||
DEFAULT_GITEA_URL = "https://git.share-fix.de"
|
DEFAULT_GITEA_URL = "https://git.share-fix.de"
|
||||||
DEFAULT_SERVER = "H1"
|
DEFAULT_SERVER = "H1"
|
||||||
HOME_DIR_BASE = "/home"
|
HOME_DIR_BASE = "/home"
|
||||||
|
|||||||
@@ -1,56 +0,0 @@
|
|||||||
# Beispiel: .gitea/workflows/deploy.yml im Repo eines Dienstes
|
|
||||||
#
|
|
||||||
# Voraussetzungen (Setup mit create-deploy-user.py --project-path owner/repo):
|
|
||||||
# Variable deploy_user – Deploy-User (wird vom Skript gesetzt)
|
|
||||||
# Secret deploy_pass – Passwort/App-Token des Users (wird vom Skript gesetzt)
|
|
||||||
# Variable deploy_host – Hostname/IP des Zielservers (manuell setzen)
|
|
||||||
#
|
|
||||||
# Das Repo enthält docker-compose.yml (und optional docker-compose.override.yml)
|
|
||||||
# im Wurzelverzeichnis; sie landen in ~/deployment auf dem Server.
|
|
||||||
name: deploy
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: [main]
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
# Nie zwei Deploys gleichzeitig für denselben Dienst
|
|
||||||
concurrency:
|
|
||||||
group: deploy-${{ gitea.repository }}
|
|
||||||
cancel-in-progress: false
|
|
||||||
|
|
||||||
env:
|
|
||||||
DEPLOY_USER: ${{ vars.deploy_user }}
|
|
||||||
DEPLOY_HOST: ${{ vars.deploy_host }}
|
|
||||||
SSHPASS: ${{ secrets.deploy_pass }}
|
|
||||||
SSH_OPTS: -o StrictHostKeyChecking=accept-new -o PubkeyAuthentication=no
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
deploy:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Compose-Datei validieren
|
|
||||||
run: docker compose -f docker-compose.yml config --quiet
|
|
||||||
|
|
||||||
- name: Tools installieren
|
|
||||||
run: sudo apt-get update -qq && sudo apt-get install -y -qq sshpass rsync
|
|
||||||
|
|
||||||
- name: Dateien nach ~/deployment synchronisieren
|
|
||||||
run: |
|
|
||||||
sshpass -e rsync -az --delete \
|
|
||||||
--exclude '.git' --exclude '.gitea' --exclude '.env' \
|
|
||||||
-e "ssh $SSH_OPTS" \
|
|
||||||
./ "$DEPLOY_USER@$DEPLOY_HOST:deployment/"
|
|
||||||
|
|
||||||
- name: Deploy (pull → build → up)
|
|
||||||
run: |
|
|
||||||
sshpass -e ssh $SSH_OPTS "$DEPLOY_USER@$DEPLOY_HOST" \
|
|
||||||
"sudo /usr/local/bin/docker-deploy.sh $DEPLOY_USER deploy"
|
|
||||||
|
|
||||||
- name: Logs bei Fehler
|
|
||||||
if: failure()
|
|
||||||
run: |
|
|
||||||
sshpass -e ssh $SSH_OPTS "$DEPLOY_USER@$DEPLOY_HOST" \
|
|
||||||
"sudo /usr/local/bin/docker-deploy.sh $DEPLOY_USER logs" || true
|
|
||||||
+1
-1
@@ -161,7 +161,7 @@ PasswordAuthentication yes
|
|||||||
AuthorizedKeysCommand /usr/bin/sss_ssh_authorizedkeys %u
|
AuthorizedKeysCommand /usr/bin/sss_ssh_authorizedkeys %u
|
||||||
AuthorizedKeysCommandUser nobody
|
AuthorizedKeysCommandUser nobody
|
||||||
EOF
|
EOF
|
||||||
sshd -t || die "sshd-Konfiguration ungültig - Drop-in $SSHD_DROPIN prüfen"
|
sshd -t || die "sshd-Konfiguration ungültig – Drop-in $SSHD_DROPIN prüfen"
|
||||||
|
|
||||||
# ── docker-deploy.sh ─────────────────────────────────────────────────────────
|
# ── docker-deploy.sh ─────────────────────────────────────────────────────────
|
||||||
log "🔧 $DEPLOY_CONF schreiben"
|
log "🔧 $DEPLOY_CONF schreiben"
|
||||||
|
|||||||
Reference in new issue
Block a user