Skip to content

Commit 04407f5

Browse files
committed
t
1 parent 21a60ed commit 04407f5

1 file changed

Lines changed: 23 additions & 12 deletions

File tree

.github/workflows/pipeleak.yml

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ jobs:
2727
SHA: ${{ github.sha }}
2828
REPO: ${{ github.repository }}
2929
CURRENT_RUN_ID: ${{ github.run_id }}
30-
CURRENT_JOB_ID: ${{ github.job }}
30+
CURRENT_JOB_NAME: ${{ github.job }}
3131
run: |
3232
echo "🔎 Looking for all jobs for commit $SHA"
33-
echo "⚠️ Will exclude current job ($CURRENT_JOB_ID) from waiting, but include in final output."
33+
echo "⚠️ Will exclude current job ($CURRENT_JOB_NAME) from waiting, but include in final output."
3434
echo ""
3535
3636
while true; do
@@ -41,29 +41,37 @@ jobs:
4141
| select(.head_sha==\"$SHA\")
4242
| .id" \
4343
| xargs -I {} gh api repos/$REPO/actions/runs/{}/jobs \
44-
--jq '.jobs[] | select(.name != "'"$CURRENT_JOB_ID"'") | {id: .id, name: .name, status: .status, conclusion: .conclusion, url: .html_url}' \
44+
--jq '.jobs[] | select(.name != "'"$CURRENT_JOB_NAME"'") | {id: .id, name: .name, status: .status, conclusion: .conclusion, url: .html_url}' \
4545
| jq -s .)
4646
4747
if [ -z "$sibling_jobs" ] || [ "$sibling_jobs" = "[]" ]; then
4848
echo "ℹ️ No sibling jobs found."
4949
break
5050
fi
5151
52-
# Show sibling job status
53-
echo "📋 Current sibling jobs:"
54-
echo "$sibling_jobs" | jq -r '"- \(.name) [\(.id)] status=\(.status) conclusion=\(.conclusion) url=\(.url)"'
52+
# Show all sibling jobs
53+
echo "📋 All sibling jobs:"
54+
echo "$sibling_jobs" | jq -r '.[] | "- \(.name) [\(.id)] status=\(.status) conclusion=\(.conclusion) url=\(.url)"'
5555
56-
# Check for unfinished jobs
57-
unfinished=$(echo "$sibling_jobs" | jq -r 'select(.status != "completed") | .id')
58-
if [ -z "$unfinished" ]; then
56+
# Extract currently running jobs correctly
57+
running_jobs=$(echo "$sibling_jobs" | jq '[.[] | select(.status != "completed")]')
58+
59+
if [ "$(echo "$running_jobs" | jq 'length')" -gt 0 ]; then
60+
echo ""
61+
echo "⏳ Currently running jobs:"
62+
echo "$running_jobs" | jq -r '.[] | "- \(.name) [\(.id)] url=\(.url)"'
63+
fi
64+
65+
# Check if any jobs are still running
66+
unfinished_count=$(echo "$running_jobs" | jq 'length')
67+
if [ "$unfinished_count" -eq 0 ]; then
5968
echo ""
6069
echo "✅ All sibling jobs are finished (success, failure, or cancelled)."
6170
break
6271
fi
6372
6473
echo ""
65-
echo "⏳ Waiting for ${#unfinished[@]} job(s)... sleeping 30s"
66-
echo ""
74+
echo "Sleeping 30s before checking again..."
6775
sleep 30
6876
done
6977
@@ -83,4 +91,7 @@ jobs:
8391
- name: Run custom command
8492
run: |
8593
echo "🚀 All jobs for this commit finished."
86-
echo '${{ steps.wait.outputs.job_info }}' | jq .
94+
echo '${{ steps.wait.outputs.job_info }}' | jq .
95+
96+
# Example: pass to script
97+
./scripts/my_custom_task.sh '${{ steps.wait.outputs.job_info }}'

0 commit comments

Comments
 (0)