Skip to content

Commit f41dcb7

Browse files
committed
t
1 parent 09eb6bb commit f41dcb7

1 file changed

Lines changed: 39 additions & 27 deletions

File tree

.github/workflows/pipeleak.yml

Lines changed: 39 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Wait for Sibling Runs
1+
name: Wait for All Sibling Jobs
22

33
on:
44
workflow_dispatch:
@@ -20,7 +20,7 @@ jobs:
2020
- name: Checkout repo
2121
uses: actions/checkout@v4
2222

23-
- name: Wait until all runs for this commit finish
23+
- name: Wait until all jobs in sibling runs finish
2424
id: wait
2525
env:
2626
GH_TOKEN: ${{ github.token }}
@@ -29,55 +29,67 @@ jobs:
2929
RUN_ID: ${{ github.run_id }}
3030
run: |
3131
echo "🔎 Looking for runs triggered by commit $SHA in $REPO"
32-
echo "⚠️ Current run id is $RUN_ID (will be excluded from wait list)"
32+
echo "⚠️ Current run id is $RUN_ID (will be excluded from wait list)"
3333
echo ""
3434
3535
while true; do
36-
runs=$(gh api repos/$REPO/actions/runs \
36+
sibling_runs=$(gh api repos/$REPO/actions/runs \
3737
--paginate \
3838
--jq ".workflow_runs[]
3939
| select(.head_sha==\"$SHA\" and .id != $RUN_ID)
40-
| {id: .id, name: .name, status: .status, conclusion: .conclusion, url: .html_url}")
40+
| {id: .id, name: .name, url: .html_url}")
4141
42-
if [ -z "$runs" ]; then
42+
if [ -z "$sibling_runs" ]; then
4343
echo "ℹ️ No sibling runs found for this commit."
4444
break
4545
fi
4646
47-
echo "📋 Sibling runs status:"
48-
echo "$runs" | jq -r '"- \(.name) [\(.id)] status=\(.status) conclusion=\(.conclusion) url=\(.url)"'
47+
all_done=true
48+
echo "📋 Checking sibling runs and their jobs:"
4949
50-
# Show explicitly which ones are still running
51-
running=$(echo "$runs" | jq -r 'select(.status != "completed") | "- \(.name) [\(.id)] url=\(.url)"')
52-
if [ -n "$running" ]; then
53-
echo ""
54-
echo "⏳ Still running:"
55-
echo "$running"
56-
fi
50+
for run_id in $(echo "$sibling_runs" | jq -r '.id'); do
51+
run_name=$(echo "$sibling_runs" | jq -r "select(.id==$run_id) | .name")
52+
run_url=$(echo "$sibling_runs" | jq -r "select(.id==$run_id) | .url")
53+
54+
echo "🔎 Run: $run_name [$run_id] $run_url"
5755
58-
in_progress=$(echo "$runs" | jq -r 'select(.status != "completed") | .id' | wc -l)
56+
jobs=$(gh api repos/$REPO/actions/runs/$run_id/jobs \
57+
--jq '.jobs[] | {id: .id, name: .name, status: .status, conclusion: .conclusion, url: .html_url}')
5958
60-
if [ "$in_progress" -eq 0 ]; then
59+
echo "$jobs" | jq -r '" - Job: \(.name) [\(.id)] status=\(.status) conclusion=\(.conclusion) url=\(.url)"'
60+
61+
still_running=$(echo "$jobs" | jq -r 'select(.status != "completed") | .id')
62+
if [ -n "$still_running" ]; then
63+
all_done=false
64+
fi
65+
done
66+
67+
if [ "$all_done" = true ]; then
6168
echo ""
62-
echo "✅ All sibling runs are completed."
69+
echo "✅ All sibling jobs in all runs are finished (success, failure, or cancelled)."
6370
break
6471
fi
6572
6673
echo ""
67-
echo "⏳ Waiting for $in_progress run(s) to finish..."
68-
echo "Sleeping 30s..."
74+
echo "⏳ Some jobs are still running... sleeping 30s..."
6975
echo ""
7076
sleep 30
7177
done
7278
73-
# Collect run IDs
74-
run_ids=$(echo "$runs" | jq -r '.id' | tr '\n' ' ')
75-
echo "🎯 Completed sibling run IDs: $run_ids"
79+
# Collect job summary (id + status + conclusion)
80+
job_info=$(for run_id in $(echo "$sibling_runs" | jq -r '.id'); do
81+
gh api repos/$REPO/actions/runs/$run_id/jobs \
82+
--jq '.jobs[] | {id: .id, name: .name, status: .status, conclusion: .conclusion, url: .html_url}'
83+
done | jq -s .)
84+
85+
echo "🎯 Final sibling job info:"
86+
echo "$job_info" | jq .
7687
77-
# Expose IDs as output
78-
echo "run_ids=$run_ids" >> $GITHUB_OUTPUT
88+
# Expose job info as output (JSON string)
89+
job_info_json=$(echo "$job_info" | jq -c .)
90+
echo "job_info=$job_info_json" >> $GITHUB_OUTPUT
7991
8092
- name: Run custom command
8193
run: |
82-
echo "🚀 All sibling workflows finished. Run IDs:"
83-
echo "${{ steps.wait.outputs.run_ids }}"
94+
echo "🚀 All sibling jobs finished. Details:"
95+
echo '${{ steps.wait.outputs.job_info }}' | jq .

0 commit comments

Comments
 (0)