Composite Action docker-deploy im Repo-Root; Beispiel-Workflow nutzt sie, plus Renovate-Beispiele
This commit is contained in:
1 parent
be80074390
commit
a5a3fab167
4 files changed
+114
-31
No files matched your search
+74
@@ -0,0 +1,74 @@
|
||||
name: docker-deploy
|
||||
description: Synchronisiert das Repo per rsync nach ~/deployment und startet docker-deploy.sh auf dem Zielserver
|
||||
|
||||
# Verwendung (siehe examples/deploy.yml):
|
||||
# - uses: actions/checkout@v4
|
||||
# - uses: https://git.share-fix.de/jochen/admin-toolsuite@v1
|
||||
# with:
|
||||
# deploy_user: ${{ vars.deploy_user }}
|
||||
# deploy_host: ${{ vars.deploy_host }}
|
||||
# deploy_pass: ${{ secrets.deploy_pass }}
|
||||
|
||||
inputs:
|
||||
deploy_user:
|
||||
description: Deploy-User auf dem Zielserver
|
||||
required: true
|
||||
deploy_host:
|
||||
description: Hostname/IP des Zielservers
|
||||
required: true
|
||||
deploy_pass:
|
||||
description: Passwort/App-Token des Deploy-Users
|
||||
required: true
|
||||
compose_file:
|
||||
description: Compose-Datei, die vor dem Deploy validiert wird
|
||||
default: docker-compose.yml
|
||||
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- name: Compose-Datei validieren
|
||||
shell: bash
|
||||
run: docker compose -f "$COMPOSE_FILE" config --quiet
|
||||
env:
|
||||
COMPOSE_FILE: ${{ inputs.compose_file }}
|
||||
|
||||
- name: Tools installieren
|
||||
shell: bash
|
||||
run: sudo apt-get update -qq && sudo apt-get install -y -qq sshpass rsync
|
||||
|
||||
- name: Dateien nach ~/deployment synchronisieren
|
||||
shell: bash
|
||||
run: |
|
||||
sshpass -e rsync -az --delete \
|
||||
--exclude '.git' --exclude '.gitea' --exclude '.env' \
|
||||
--filter=':- .gitignore' \
|
||||
-e "ssh $SSH_OPTS" \
|
||||
./ "$DEPLOY_USER@$DEPLOY_HOST:deployment/"
|
||||
env:
|
||||
DEPLOY_USER: ${{ inputs.deploy_user }}
|
||||
DEPLOY_HOST: ${{ inputs.deploy_host }}
|
||||
SSHPASS: ${{ inputs.deploy_pass }}
|
||||
SSH_OPTS: -o StrictHostKeyChecking=accept-new -o PubkeyAuthentication=no
|
||||
|
||||
- name: Deploy (pull → build → up)
|
||||
shell: bash
|
||||
run: |
|
||||
sshpass -e ssh $SSH_OPTS "$DEPLOY_USER@$DEPLOY_HOST" \
|
||||
"sudo /usr/local/bin/docker-deploy.sh $DEPLOY_USER deploy"
|
||||
env:
|
||||
DEPLOY_USER: ${{ inputs.deploy_user }}
|
||||
DEPLOY_HOST: ${{ inputs.deploy_host }}
|
||||
SSHPASS: ${{ inputs.deploy_pass }}
|
||||
SSH_OPTS: -o StrictHostKeyChecking=accept-new -o PubkeyAuthentication=no
|
||||
|
||||
- name: Logs bei Fehler
|
||||
if: failure()
|
||||
shell: bash
|
||||
run: |
|
||||
sshpass -e ssh $SSH_OPTS "$DEPLOY_USER@$DEPLOY_HOST" \
|
||||
"sudo /usr/local/bin/docker-deploy.sh $DEPLOY_USER logs" || true
|
||||
env:
|
||||
DEPLOY_USER: ${{ inputs.deploy_user }}
|
||||
DEPLOY_HOST: ${{ inputs.deploy_host }}
|
||||
SSHPASS: ${{ inputs.deploy_pass }}
|
||||
SSH_OPTS: -o StrictHostKeyChecking=accept-new -o PubkeyAuthentication=no
|
||||
+8
-31
@@ -1,5 +1,8 @@
|
||||
# Beispiel: .gitea/workflows/deploy.yml im Repo eines Dienstes
|
||||
#
|
||||
# Die eigentliche Logik liegt als Composite Action in diesem Repo (action.yml).
|
||||
# Die Version (@v1.0.0) wird von Renovate per PR aktualisiert (siehe renovate.json).
|
||||
#
|
||||
# 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)
|
||||
@@ -19,39 +22,13 @@ 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' \
|
||||
--filter=':- .gitignore' \
|
||||
-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
|
||||
- uses: https://git.share-fix.de/jochen/admin-toolsuite@v1.0.0
|
||||
with:
|
||||
deploy_user: ${{ vars.deploy_user }}
|
||||
deploy_host: ${{ vars.deploy_host }}
|
||||
deploy_pass: ${{ secrets.deploy_pass }}
|
||||
@@ -0,0 +1,27 @@
|
||||
# Beispiel: .gitea/workflows/renovate.yml (einmal zentral oder pro Repo)
|
||||
#
|
||||
# Voraussetzungen:
|
||||
# Secret RENOVATE_TOKEN - Gitea-Token des Bot-Users (Rechte: repository r/w, issue r/w, user r)
|
||||
# Secret GITHUB_COM_TOKEN - optional, nur für Release-Notes/Rate-Limits von github.com
|
||||
name: renovate
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: "0 4 * * *"
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
renovate:
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: renovate/renovate:latest
|
||||
steps:
|
||||
- name: Renovate ausführen
|
||||
run: renovate
|
||||
env:
|
||||
RENOVATE_PLATFORM: gitea
|
||||
RENOVATE_ENDPOINT: https://git.share-fix.de/api/v1
|
||||
RENOVATE_TOKEN: ${{ secrets.RENOVATE_TOKEN }}
|
||||
GITHUB_COM_TOKEN: ${{ secrets.GITHUB_COM_TOKEN }}
|
||||
RENOVATE_AUTODISCOVER: "true"
|
||||
LOG_LEVEL: info
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
||||
"extends": ["config:recommended"],
|
||||
"enabledManagers": ["github-actions"]
|
||||
}
|
||||
Reference in new issue
Block a user