Skip to content

Commit 6dfd7d8

Browse files
committed
feat: wait for pipeline
1 parent 1b7a3db commit 6dfd7d8

1 file changed

Lines changed: 47 additions & 0 deletions

File tree

.github/workflows/orca.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ defaults:
1616

1717
jobs:
1818
trigger_orca:
19+
name: orca
1920
runs-on: ubuntu-latest
2021
steps:
2122
- name: trigger orca pipeline
@@ -42,3 +43,49 @@ jobs:
4243
echo "Pipeline triggered successfully!"
4344
echo "Pipeline URL: $web_url"
4445
echo "Pipeline URL: <$web_url>" >> $GITHUB_STEP_SUMMARY
46+
- name: wait for orca pipeline
47+
env:
48+
GITLAB_TOKEN: ${{ secrets.ORCA_READ_TOKEN }}
49+
PIPELINE_ID: ${{ steps.trigger.outputs.pipeline_id }}
50+
PIPELINE_URL: ${{ steps.trigger.outputs.web_url }}
51+
TIMEOUT: 3600
52+
run: |
53+
echo "Waiting for pipeline to complete..."
54+
elapsed=0
55+
sleep_interval=60
56+
while [ $elapsed -lt $TIMEOUT ]; do
57+
status=$(curl -s -H "PRIVATE-TOKEN: $GITLAB_TOKEN" \
58+
"https://gitlab.com/api/v4/projects/${{ secrets.ORCA_PROJECT_ID }}/pipelines/$PIPELINE_ID" \
59+
| jq -r '.status')
60+
echo "Current status: $status (elapsed: ${elapsed}s)"
61+
case $status in
62+
"success")
63+
echo "Pipeline completed successfully!"
64+
exit 0
65+
;;
66+
"failed")
67+
echo "Pipeline failed!"
68+
exit 1
69+
;;
70+
"canceled")
71+
echo "Pipeline was canceled!"
72+
exit 1
73+
;;
74+
"skipped")
75+
echo "Pipeline was skipped!"
76+
exit 1
77+
;;
78+
"running"|"pending"|"created")
79+
echo "Pipeline is still running..."
80+
sleep $sleep_interval
81+
elapsed=$((elapsed + sleep_interval))
82+
;;
83+
*)
84+
echo "Unknown status: $status"
85+
sleep $sleep_interval
86+
elapsed=$((elapsed + sleep_interval))
87+
;;
88+
esac
89+
done
90+
echo "Timeout waiting for pipeline to complete"
91+
exit 1

0 commit comments

Comments
 (0)