Skip to content

Commit

Permalink
Test fail command
Browse files Browse the repository at this point in the history
  • Loading branch information
cytopia committed Nov 17, 2022
1 parent 5c750d3 commit 43fb110
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
21 changes: 19 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ on:
pull_request:

jobs:
build:
name: test
test-default:
name: test success
runs-on: ubuntu-latest
steps:

Expand All @@ -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"
8 changes: 8 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand All @@ -51,3 +58,4 @@ runs:
PAUSE: ${{ inputs.pause }}
COMMAND: ${{ inputs.command }}
WORKDIR: ${{ inputs.workdir }}
FAIL_COMMAND: ${{ inputs.fail_command }}

0 comments on commit 43fb110

Please sign in to comment.