From 82b726cecd3ed7ecd7385d45197c41ceb9293bb2 Mon Sep 17 00:00:00 2001 From: Stanislav Ulrych Date: Sat, 4 Jan 2025 20:39:13 +0100 Subject: [PATCH] feat: added repeat action --- action.yml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 action.yml diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..93a63cd --- /dev/null +++ b/action.yml @@ -0,0 +1,32 @@ +name: 'Repeat Action' +description: 'Repeat given command n times or until succeeds' +inputs: + command: + description: 'Command to execute' + required: true + count: + description: 'Count of repetitions' + required: false + default: 1 +outputs: + status: + description: "Exit value of the command (error if no execution was successful)" + value: ${{ steps.repeat.outputs.status }} +runs: + using: "composite" + steps: + - name: Run action + id: repeat + shell: bash + run: | + for i in $(seq 1 ${{ inputs.count }}); + do + echo "$i: ${{ inputs.command }}" + { ${{ inputs.command }} ; status=$?; } || true + echo "$i: status=$status" + if [[ "$status" -eq 0 ]] + then + break + fi + done + echo "statusr=$status" >> $GITHUB_OUTPUT