Skip to content

Commit

Permalink
Want to try using a bash array to pass in the extra arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
Soren Ptak committed Jul 21, 2023
1 parent e768b9d commit 7beccde
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions executable-monitor/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,42 +46,42 @@ runs:
run: |
# Run Executable with Monitoring
echo "::group::Argument Parsing"
optArgs=""
optArgs=("")
# Make sure we have an exit condition to look for
if [ "${{ inputs.success-exit-code }}" = "" ] && [ "${{ inputs.success-line }}" = "" ]; then
echo "::endgroup::"
echo -e "\033[32;31mDid not supply an input of success-line or success-exit-code to search for\033[0m"
exit 1
fi
# Check if an exit code was provided
if [ "${{ inputs.success-exit-code }}" != "" ]; then
optArgs="$optArgs --success-exit-code=${{ inputs.success-exit-code }}"
optArgs+=(--success-exit-code=${{ inputs.success-exit-code }})
fi
# Check for log directory/if a log file should be created
if [ "${{ inputs.log-dir }}" != "" ]; then
optArgs="$optArgs --log-dir=${{ inputs.log-dir}}"
optArgs+=(--log-dir=${{ inputs.log-dir}})
fi
# Check for retry attempts
if [ "${{ inputs.retry-attempts }}" != "" ]; then
optArgs="$optArgs --retry-attempts=${{ inputs.retry-attempts}}"
optArgs+=(--retry-attempts=${{ inputs.retry-attempts}})
fi
# Check if a success line was provided
if [ "${{ inputs.success-line }}" != "" ]; then
optArgs="$optArgs --success-line=\"${{ inputs.success-line}}\""
optArgs+=("$optArgs --success-line=\"${{ inputs.success-line}}\")
fi
# Set +e so that an exit code doesn't cause immediately failure. Allows printing exit status string
set +e
# End the group about parsing the inputs, print the line that will be run, then create a new echo group
echo "::endgroup::"
echo -e "\033[1;33mRunning Command: python3 $GITHUB_ACTION_PATH/executable-monitor.py --exe-path=${{ inputs.exe-path }} --timeout-seconds=${{ inputs.timeout-seconds }} $optArgs\033[0m"
echo -e "\033[1;33mRunning Command: python3 $GITHUB_ACTION_PATH/executable-monitor.py --exe-path=${{ inputs.exe-path }} --timeout-seconds=${{ inputs.timeout-seconds }} ${optArgs[@]}[0m"
echo "::group::Executable Output"
python3 $GITHUB_ACTION_PATH/executable-monitor.py --exe-path=${{ inputs.exe-path }} --timeout-seconds=${{ inputs.timeout-seconds }} $optArgs
python3 $GITHUB_ACTION_PATH/executable-monitor.py --exe-path=${{ inputs.exe-path }} --timeout-seconds=${{ inputs.timeout-seconds }} ${optArgs[@]}
# Need to store the status as the endgroup echo will count for the $? check
exitStatus=$?
Expand Down

0 comments on commit 7beccde

Please sign in to comment.