Skip to content

feat(ci): trigger orca #5

feat(ci): trigger orca

feat(ci): trigger orca #5

Workflow file for this run

name: orca
on:
pull_request:
push:
branches: [ development ]
tags: [ '*' ]
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
defaults:
run:
shell: bash
jobs:
trigger_orca:
name: orca
runs-on: ubuntu-latest
steps:
- name: trigger orca pipeline
id: trigger
run: |
response=$(curl -X POST \
-F "token=${{ secrets.ORCA_TRIGGER_TOKEN }}" \
-F "ref=main" \
-F "variables[TRIGGERED_BY]=github" \
-F "variables[GITHUB_REPO]=${{ github.repository }}" \
-F "variables[GITHUB_SHA]=${{ github.sha }}" \
-F "variables[GITHUB_RUN_ID]=${{ github.run_id }}" \
-F "variables[REF_COATJAVA]=${{ github.head_ref || github.ref_name }}" \
"https://code.jlab.org/api/v4/projects/${{ secrets.ORCA_PROJECT_ID }}/trigger/pipeline")
echo "RESPONSE: $response"
pipeline_id=$(echo $response | jq -r '.id')
web_url=$(echo $response | jq -r '.web_url')
if [ "$pipeline_id" == "null" ] || [ -z "$pipeline_id" ]; then
echo "ERROR: Failed to trigger pipeline" >&2
exit 1
fi
echo "pipeline_id=$pipeline_id" >> $GITHUB_OUTPUT
echo "web_url=$web_url" >> $GITHUB_OUTPUT
echo "Pipeline triggered successfully!"
echo "Pipeline URL: $web_url"
echo "Pipeline URL: <$web_url>" >> $GITHUB_STEP_SUMMARY
- name: wait for orca pipeline
env:
GITLAB_TOKEN: ${{ secrets.ORCA_READ_TOKEN }}
PIPELINE_ID: ${{ steps.trigger.outputs.pipeline_id }}
PIPELINE_URL: ${{ steps.trigger.outputs.web_url }}
TIMEOUT: 3600
run: |
echo "Waiting for pipeline to complete..."
elapsed=0
sleep_interval=60
while [ $elapsed -lt $TIMEOUT ]; do
status=$(curl -s -H "PRIVATE-TOKEN: $GITLAB_TOKEN" \
"https://gitlab.com/api/v4/projects/${{ secrets.ORCA_PROJECT_ID }}/pipelines/$PIPELINE_ID" \
| jq -r '.status')
echo "Current status: $status (elapsed: ${elapsed}s)"
case $status in
"success")
echo "Pipeline completed successfully!"
exit 0
;;
"failed")
echo "Pipeline failed!"
exit 1
;;
"canceled")
echo "Pipeline was canceled!"
exit 1
;;
"skipped")
echo "Pipeline was skipped!"
exit 1
;;
"running"|"pending"|"created")
echo "Pipeline is still running..."
sleep $sleep_interval
elapsed=$((elapsed + sleep_interval))
;;
*)
echo "Unknown status: $status"
sleep $sleep_interval
elapsed=$((elapsed + sleep_interval))
;;
esac
done
echo "Timeout waiting for pipeline to complete"
exit 1