diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..bd47ef9 --- /dev/null +++ b/action.yml @@ -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 diff --git a/examples/deploy.yml b/examples/deploy.yml index 22e58df..736cfbc 100644 --- a/examples/deploy.yml +++ b/examples/deploy.yml @@ -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 }} diff --git a/examples/renovate-workflow.yml b/examples/renovate-workflow.yml new file mode 100644 index 0000000..89e78ee --- /dev/null +++ b/examples/renovate-workflow.yml @@ -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 diff --git a/examples/renovate.json b/examples/renovate.json new file mode 100644 index 0000000..f5504ee --- /dev/null +++ b/examples/renovate.json @@ -0,0 +1,5 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "extends": ["config:recommended"], + "enabledManagers": ["github-actions"] +}