Composite Action docker-deploy
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
36e78cd400
2 files changed
+108
No files matched your search
@@ -0,0 +1,34 @@
|
||||
# deploy-action
|
||||
|
||||
Composite Action für Gitea Actions: synchronisiert das Repo per rsync nach `~/deployment`
|
||||
auf dem Zielserver und startet dort `docker-deploy.sh deploy`.
|
||||
|
||||
Das Repo muss **öffentlich** sein, weil der Runner Actions anonym klont.
|
||||
|
||||
## Verwendung
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: https://git.share-fix.de/jochen/deploy-action@v1.0.0
|
||||
with:
|
||||
deploy_user: ${{ vars.deploy_user }}
|
||||
deploy_host: ${{ vars.deploy_host }}
|
||||
deploy_pass: ${{ secrets.deploy_pass }}
|
||||
```
|
||||
|
||||
Das vollständige Beispiel-Workflow liegt in `admin-toolsuite/examples/deploy.yml`;
|
||||
`create-deploy-user.py` legt es im Service-Repo an und setzt Variablen und Secret.
|
||||
|
||||
## Inputs
|
||||
|
||||
| Input | Pflicht | Beschreibung |
|
||||
|---|---|---|
|
||||
| `deploy_user` | ja | Deploy-User auf dem Zielserver |
|
||||
| `deploy_host` | ja | Hostname des Zielservers |
|
||||
| `deploy_pass` | ja | Passwort/App-Token des Deploy-Users |
|
||||
| `compose_file` | nein | Compose-Datei zur Validierung (Standard `docker-compose.yml`) |
|
||||
|
||||
## Releases
|
||||
|
||||
Semver-Tags (`v1.0.0`, …). Renovate bumpt den Tag in den Service-Repos per PR.
|
||||
+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 README.md):
|
||||
# - uses: actions/checkout@v4
|
||||
# - uses: https://git.share-fix.de/jochen/deploy-action@v1.0.0
|
||||
# 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
|
||||
Reference in new issue
Block a user