Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Bar Magnezi authored and Bar Magnezi committed Dec 22, 2021
1 parent 8316c2d commit aeb203e
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/commands/trigger-workflows-for-all-modified.yml
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,7 @@ steps:
workflow_id=$(jq -r .id /tmp/swissknife/triggered_workflow.json)
echo ""
echo "Waiting for workflow: ${workflow_id} to complete"
if (( $total == 0 )); then
sleep << parameters.sleep-time-between-checks >>
fi
total_wait_time=0
while true; do
workflow_status=/tmp/swissknife/workflow_status.json
Expand All @@ -291,12 +289,13 @@ steps:
running=$(jq -s 'map(select(.status == "running")) | length' ${workflow_status})
success=$(jq -s 'map(select(.status == "success")) | length' ${workflow_status})
echo "total: ${total}, running: ${running}, success: ${success}"
if (( $total == 0 )); then
if (( $total == 0 && $total_wait_time > 0 )); then
echo "No running workflows, return success"
exit 0
elif (( $running > 0 )); then
elif (( $total_wait_time == 0 || $running > 0 )); then
echo "Going to sleep for << parameters.sleep-time-between-checks >>"
sleep << parameters.sleep-time-between-checks >>
total_wait_time=$((total_wait_time+<< parameters.sleep-time-between-checks >>))
elif (( $total == $success )); then
echo "Great success"
exit 0
Expand Down

0 comments on commit aeb203e

Please sign in to comment.