From 43fb110e69c95d78ef37f28362c121b970f723c9 Mon Sep 17 00:00:00 2001 From: cytopia Date: Thu, 17 Nov 2022 15:03:37 +0100 Subject: [PATCH] Test fail command --- .github/workflows/test.yml | 21 +++++++++++++++++++-- action.yml | 8 ++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5574b9c..8ad1cec 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -4,8 +4,8 @@ on: pull_request: jobs: - build: - name: test + test-default: + name: test success runs-on: ubuntu-latest steps: @@ -18,3 +18,20 @@ jobs: uses: ./ with: command: true + + test-fail-command: + name: test fail command + runs-on: ubuntu-latest + steps: + + - name: Checkout repository + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: retry + uses: ./ + with: + command: false + fail_command: | + echo "This command has failed" diff --git a/action.yml b/action.yml index 62ebaf7..6e6047a 100644 --- a/action.yml +++ b/action.yml @@ -19,6 +19,10 @@ inputs: description: 'Shell command to execute' required: true default: 'true' + fail_command: + description: 'Shell command to execute on every failure of given command (The fail_command will always succeed via: || true)' + required: false + default: '' workdir: description: 'Switch to this working directory prior executing shell command' required: false @@ -37,6 +41,9 @@ runs: echo "[SUCC] ${n}/${RETRIES}"; return 0; fi; + if [ -n "${FAIL_COMMAND}" ]; then + eval "${FAIL_COMMAND}" || true; + fi; sleep ${PAUSE}; echo "[FAIL] ${n}/${RETRIES}"; done; @@ -51,3 +58,4 @@ runs: PAUSE: ${{ inputs.pause }} COMMAND: ${{ inputs.command }} WORKDIR: ${{ inputs.workdir }} + FAIL_COMMAND: ${{ inputs.fail_command }}