@@ -87,32 +87,40 @@ jobs:
8787 name : Wait for all workflow runs to complete
8888 run : |
8989 PR_NUMBER=$(echo "$PR_URL" | grep -oP '\d+$')
90- echo "Waiting for all checks to complete on PR #${PR_NUMBER}..."
90+ echo "Waiting for all workflow runs to complete on PR #${PR_NUMBER}..."
91+
92+ # Get the PR's head SHA
93+ HEAD_SHA=$(gh pr view "$PR_NUMBER" --json headRefOid --jq '.headRefOid')
94+ echo "Head SHA: ${HEAD_SHA}"
9195
9296 MAX_WAIT=600 # 10 minutes max wait
9397 ELAPSED=0
9498 SLEEP_INTERVAL=10
9599
96100 while [ $ELAPSED -lt $MAX_WAIT ]; do
97- # Get all workflow runs for this PR's head SHA
98- PR_DATA=$(gh pr view "$PR_NUMBER" --json headRefOid,statusCheckRollup)
99- HEAD_SHA=$(echo "$PR_DATA" | jq -r '.headRefOid')
101+ # Get all workflow runs for this SHA using the GitHub API
102+ RUNS=$(gh api "/repos/${{ github.repository }}/actions/runs?head_sha=${HEAD_SHA}&per_page=100" --jq '.workflow_runs')
100103
101- # Check if any workflows are still in progress
102- IN_PROGRESS=$(echo "$PR_DATA " | jq -r '.statusCheckRollup [] | select(.status == "IN_PROGRESS " or .status == "QUEUED " or .status == "PENDING") | .name' | wc -l )
104+ # Count how many are still in progress, queued, or waiting
105+ IN_PROGRESS=$(echo "$RUNS " | jq '[. [] | select(.status == "in_progress " or .status == "queued " or .status == "waiting")] | length' )
103106
104107 if [ "$IN_PROGRESS" -eq 0 ]; then
105108 echo "::notice::All workflow runs completed for SHA ${HEAD_SHA}"
109+ TOTAL_RUNS=$(echo "$RUNS" | jq 'length')
110+ echo "Total workflow runs: ${TOTAL_RUNS}"
106111 break
107112 fi
108113
109- echo "Still waiting for $IN_PROGRESS check(s) to complete..."
114+ # Show which workflows are still running
115+ RUNNING=$(echo "$RUNS" | jq -r '.[] | select(.status == "in_progress" or .status == "queued" or .status == "waiting") | .name' | tr '\n' ', ' | sed 's/,$//')
116+ echo "Still waiting for ${IN_PROGRESS} workflow run(s): ${RUNNING}"
117+
110118 sleep $SLEEP_INTERVAL
111119 ELAPSED=$((ELAPSED + SLEEP_INTERVAL))
112120 done
113121
114122 if [ $ELAPSED -ge $MAX_WAIT ]; then
115- echo "::warning::Timeout waiting for all checks to complete, proceeding anyway"
123+ echo "::warning::Timeout waiting for all workflow runs to complete, proceeding anyway"
116124 fi
117125 -
118126 name : Auto-merge PR
0 commit comments