File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -57,19 +57,26 @@ jobs:
5757 shell : bash
5858 run : |
5959 set -euo pipefail
60- latest=$(gh api "repos/$GH_REPO/actions/workflows/e2e-gate.yml/runs?event=pull_request&head_sha=$HEAD_SHA" \
61- --jq '.workflow_runs | sort_by(.created_at) | reverse | .[0] // empty')
62- if [ -z "$latest" ]; then
63- echo "No pull_request-triggered E2E Gate run found for $HEAD_SHA — nothing to re-run."
64- exit 0
65- fi
60+ for attempt in {1..60}; do
61+ latest=$(gh api "repos/$GH_REPO/actions/workflows/e2e-gate.yml/runs?event=pull_request&head_sha=$HEAD_SHA" \
62+ --jq '.workflow_runs | sort_by(.created_at) | reverse | .[0] // empty')
63+ if [ -z "$latest" ]; then
64+ echo "No pull_request-triggered E2E Gate run found for $HEAD_SHA — nothing to re-run."
65+ exit 0
66+ fi
6667
67- run_id=$(jq -r '.id' <<< "$latest")
68- status=$(jq -r '.status' <<< "$latest")
69- if [ "$status" != "completed" ]; then
70- echo "E2E Gate run $run_id is already $status for $HEAD_SHA — no new re-run needed."
71- exit 0
72- fi
68+ run_id=$(jq -r '.id' <<< "$latest")
69+ status=$(jq -r '.status' <<< "$latest")
70+ if [ "$status" = "completed" ]; then
71+ break
72+ fi
73+ if [ "$attempt" -eq 60 ]; then
74+ echo "E2E Gate run $run_id is still $status for $HEAD_SHA — leaving the active run to update the PR check."
75+ exit 0
76+ fi
77+ echo "E2E Gate run $run_id is $status for $HEAD_SHA; waiting before requesting a rerun."
78+ sleep 2
79+ done
7380
7481 echo "Re-running E2E Gate run $run_id so it re-evaluates and posts a fresh check on the PR."
7582 if ! output=$(gh api --method POST "repos/$GH_REPO/actions/runs/$run_id/rerun" 2>&1); then
You can’t perform that action at this time.
0 commit comments