Skip to content

Commit d6f50a5

Browse files
committed
feat: cancel orca if caller is cancelled
1 parent a4289ea commit d6f50a5

1 file changed

Lines changed: 21 additions & 2 deletions

File tree

.github/workflows/orca.yml

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ jobs:
5555
needs:
5656
- orca_trigger
5757
steps:
58-
- name: trigger orca pipeline
59-
id: trigger
58+
- name: wait for orca pipeline
6059
env:
6160
TIMEOUT: 3600
6261
SLEEP_INTERVAL: 60
@@ -103,3 +102,23 @@ jobs:
103102
done
104103
echo "Timeout waiting for pipeline to complete"
105104
exit 1
105+
- name: cancel pipeline if caller is cancelled
106+
if: cancelled() && needs.orca_trigger.outputs.pipeline_id
107+
run: |
108+
echo "GitHub workflow was cancelled, cancelling orca pipeline..."
109+
response=$(curl \
110+
--silent \
111+
--show-error \
112+
--write-out "\n%{http_code}" \
113+
--request POST \
114+
--header "PRIVATE-TOKEN: ${{ secrets.ORCA_READ_TOKEN }}" \
115+
"https://code.jlab.org/api/v4/projects/${{ secrets.ORCA_PROJECT_ID }}/pipelines/${{ needs.orca_trigger.outputs.pipeline_id }}/cancel")
116+
http_code=$(echo "$response" | tail -n1)
117+
response_body=$(echo "$response" | sed '$d')
118+
if [ "$http_code" -eq 200 ] || [ "$http_code" -eq 201 ]; then
119+
echo "GitLab pipeline cancelled successfully"
120+
else
121+
echo "Failed to cancel GitLab pipeline (HTTP $http_code)"
122+
echo "Response: $response_body"
123+
exit 1
124+
fi

0 commit comments

Comments
 (0)