From adcc32350970a98256288e4674817b4bde7fe9f8 Mon Sep 17 00:00:00 2001 From: Matthias Endler Date: Mon, 7 Oct 2024 12:01:03 +0200 Subject: [PATCH] Propagate exit code --- action.yml | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/action.yml b/action.yml index cdd1a78..87bca77 100644 --- a/action.yml +++ b/action.yml @@ -94,9 +94,22 @@ runs: rm -f lychee*!(lychee-bin|lychee-lib) shell: bash - - name: Run lychee - id: lychee - run: ${{ github.action_path }}/entrypoint.sh + - name: Run Lychee + id: run-lychee + run: | + # This step runs lychee and captures its exit code. + # We use 'set +e' to prevent the script from exiting immediately if lychee fails. + # This allows us to capture the exit code and pass it both to GitHub Actions (via GITHUB_OUTPUT) + # and to the shell (via the final 'exit $EXIT_CODE'). + # This ensures that: + # 1. The step fails if lychee fails + # 2. The exit code is available as an output for subsequent steps + # 3. The exit code is properly propagated to the workflow + set +e + ${{ github.action_path }}/entrypoint.sh + EXIT_CODE=$? + echo "exit_code=$EXIT_CODE" >> $GITHUB_OUTPUT + exit $EXIT_CODE env: # https://github.com/actions/runner/issues/665 INPUT_TOKEN: ${{ inputs.TOKEN }}