File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 5656
5757 run : |
5858 echo "Triggering ${{ inputs.workflow_file }} in ${{ inputs.target_repo }} on ref ${{ inputs.ref }}..."
59+ export TRIGGER_TIME=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
60+ echo "TRIGGER_TIME=$TRIGGER_TIME" >> $GITHUB_ENV
5961
6062 curl -s -o /dev/null -w "%{http_code}" -X POST \
6163 -H "Accept: application/vnd.github+json" \
@@ -79,15 +81,21 @@ jobs:
7981 echo "Waiting up to $WAIT_TIMEOUT seconds for workflow run to appear..."
8082
8183 WAIT_ITER=$((WAIT_TIMEOUT / POLL_FREQ))
82- sleep 10 # Sleep for a while to get the new workflow started
84+ sleep 3 # Sleep for a while to get the new workflow started
8385 for ((i=0; i<WAIT_ITER; i++)); do
8486 set +e
8587
8688 RESPONSE=$(curl -s -H "Authorization: Bearer $GH_TOKEN" \
8789 "https://api.github.com/repos/$OWNER/$REPO/actions/workflows/$WORKFLOW_FILE/runs?branch=$REF&event=workflow_dispatch")
8890
89- RUN_ID=$(echo "$RESPONSE" | jq -r '.workflow_runs | sort_by(.created_at) | last | .id' 2>/dev/null)
90-
91+ RUN_ID=$(echo "$RESPONSE" | jq -r --arg trigger_time "$TRIGGER_TIME" '
92+ if (.workflow_runs | type == "array") then
93+ .workflow_runs
94+ | map(select(.created_at > $trigger_time))
95+ | sort_by(.created_at)
96+ | last
97+ | .id
98+ else empty end')
9199 set -e
92100
93101 if [[ "$RUN_ID" != "null" && -n "$RUN_ID" ]]; then
You can’t perform that action at this time.
0 commit comments