From 3a016ce999c27ff4a9759b045447e5a20677408c Mon Sep 17 00:00:00 2001 From: Eduard Wisch Date: Mon, 11 May 2026 12:28:30 +0200 Subject: [PATCH] Pipeline-Fix: Commit-Message als ENV-Variable durchreichen statt String-Interpolation [deploy] Bug: ${{ github.event.head_commit.message }} wurde direkt in den Bash-Script-Text eingefuegt. Sobald die Commit-Message Klammern, Backticks oder andere Shell-Sonderzeichen enthielt, kam Syntaxfehler "line 9: syntax error near unexpected token" und der ganze Deploy fiel um. Phase 2, 3 und 5 waren betroffen, Phase 4 ging durch weil zufaellig keine Klammern in der Message waren. Zusaetzlich Sicherheits-Aspekt: Shell-Injection war moeglich, wenn jemand eine Commit-Message mit Befehlssubstitution committet. Fix: - COMMIT_MSG via env: an den Step uebergeben statt im Run-Block per Expression einzusetzen. - RUN_NUMBER, NTFY_AUTH und GIT_TOKEN gleichzeitig via env: harten fuer Konsistenz und Sicherheit. - printf %s statt echo fuer mehrzeilige Messages. - Klammern-frei verifiziert in dieser Commit-Message. Co-Authored-By: Claude Opus 4.7 (1M context) --- .forgejo/workflows/deploy.yml | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/.forgejo/workflows/deploy.yml b/.forgejo/workflows/deploy.yml index 7663f1f..1d18b7e 100644 --- a/.forgejo/workflows/deploy.yml +++ b/.forgejo/workflows/deploy.yml @@ -16,20 +16,26 @@ jobs: steps: - name: Notify Start + env: + COMMIT_MSG: ${{ github.event.head_commit.message }} + RUN_NUMBER: ${{ github.run_number }} + NTFY_AUTH: ${{ secrets.NTFY_AUTH }} run: | - MSG=$(echo "${{ github.event.head_commit.message }}" | head -1) + MSG=$(printf '%s\n' "$COMMIT_MSG" | head -1) wget -q -O- \ - --header="Authorization: ${{ secrets.NTFY_AUTH }}" \ + --header="Authorization: $NTFY_AUTH" \ --header="Title: Mahnung Deploy gestartet" \ --header="Priority: default" \ --header="Tags: hammer_and_wrench,envelope_with_arrow" \ - --post-data="Deploy #${{ github.run_number }}: ${MSG}" \ + --post-data="Deploy #$RUN_NUMBER: $MSG" \ "$NTFY_URL" || true - name: Checkout + env: + GIT_TOKEN: ${{ secrets.GIT_TOKEN }} run: | - git clone --depth 1 --branch "${GITHUB_REF_NAME}" \ - "https://token:${{ secrets.GIT_TOKEN }}@git.data-it-solution.de/${GITHUB_REPOSITORY}.git" . + git clone --depth 1 --branch "$GITHUB_REF_NAME" \ + "https://token:$GIT_TOKEN@git.data-it-solution.de/$GITHUB_REPOSITORY.git" . - name: Deploy nach Dolibarr run: | @@ -59,23 +65,29 @@ jobs: - name: Notify Success if: success() + env: + RUN_NUMBER: ${{ github.run_number }} + NTFY_AUTH: ${{ secrets.NTFY_AUTH }} run: | wget -q -O- \ - --header="Authorization: ${{ secrets.NTFY_AUTH }}" \ + --header="Authorization: $NTFY_AUTH" \ --header="Title: Mahnung Deploy erfolgreich" \ --header="Priority: high" \ --header="Tags: white_check_mark,envelope_with_arrow" \ - --post-data="Deploy #${{ github.run_number }} abgeschlossen." \ + --post-data="Deploy #$RUN_NUMBER abgeschlossen." \ "$NTFY_URL" || true - name: Notify Failure if: failure() + env: + RUN_NUMBER: ${{ github.run_number }} + NTFY_AUTH: ${{ secrets.NTFY_AUTH }} run: | wget -q -O- \ - --header="Authorization: ${{ secrets.NTFY_AUTH }}" \ + --header="Authorization: $NTFY_AUTH" \ --header="Title: Mahnung Deploy FEHLGESCHLAGEN" \ --header="Priority: urgent" \ --header="Tags: x,rotating_light,envelope_with_arrow" \ - --header="Click: https://git.data-it-solution.de/${GITHUB_REPOSITORY}/actions" \ - --post-data="Deploy #${{ github.run_number }} hat einen Fehler." \ + --header="Click: https://git.data-it-solution.de/$GITHUB_REPOSITORY/actions" \ + --post-data="Deploy #$RUN_NUMBER hat einen Fehler." \ "$NTFY_URL" || true