Skip to content

Commit a302df4

Browse files
committed
refactor: env
1 parent c08cddb commit a302df4

1 file changed

Lines changed: 13 additions & 9 deletions

File tree

.github/workflows/orca.yml

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@ defaults:
1414
run:
1515
shell: bash
1616

17+
env:
18+
ORCA_ENDPOINT: https://code.jlab.org/api/v4/projects/${{ secrets.ORCA_PROJECT_ID }}
19+
ORCA_PROJECT_TOKEN: ${{ secrets.ORCA_PROJECT_TOKEN }}
20+
ORCA_TRIGGER_TOKEN: ${{ secrets.ORCA_TRIGGER_TOKEN }}
21+
TIMEOUT: 3600 # how long to wait overall [s]
22+
SLEEP_INTERVAL: 60 # duration between each pipeline-status check [s]
23+
1724
jobs:
1825

1926
orca_trigger:
@@ -29,15 +36,15 @@ jobs:
2936
response=$(curl \
3037
--silent --show-error --fail \
3138
--request POST \
32-
--form "token=${{ secrets.ORCA_TRIGGER_TOKEN }}" \
39+
--form "token=$ORCA_TRIGGER_TOKEN" \
3340
--form "ref=main" \
3441
--form "variables[TRIGGERED_BY]=github" \
3542
--form "variables[GITHUB_EVENT]=${{ github.event_name }}" \
3643
--form "variables[GITHUB_REPO]=${{ github.repository }}" \
3744
--form "variables[GITHUB_SHA]=${{ github.sha }}" \
3845
--form "variables[GITHUB_RUN_ID]=${{ github.run_id }}" \
3946
--form "variables[REF_COATJAVA]=${{ github.head_ref || github.ref_name }}" \
40-
"https://code.jlab.org/api/v4/projects/${{ secrets.ORCA_PROJECT_ID }}/trigger/pipeline")
47+
"$ORCA_ENDPOINT/trigger/pipeline")
4148
echo "RESPONSE: $response"
4249
pipeline_id=$(echo $response | jq -r '.id')
4350
web_url=$(echo $response | jq -r '.web_url')
@@ -58,17 +65,14 @@ jobs:
5865
- orca_trigger
5966
steps:
6067
- name: wait for orca pipeline
61-
env:
62-
TIMEOUT: 3600
63-
SLEEP_INTERVAL: 60
6468
run: |
6569
echo "Waiting for pipeline to complete..."
6670
elapsed=0
6771
while [ $elapsed -lt $TIMEOUT ]; do
6872
response=$(curl \
6973
--silent --show-error --fail \
70-
--header "PRIVATE-TOKEN: ${{ secrets.ORCA_PROJECT_TOKEN }}" \
71-
"https://code.jlab.org/api/v4/projects/${{ secrets.ORCA_PROJECT_ID }}/pipelines/${{ needs.orca_trigger.outputs.pipeline_id }}")
74+
--header "PRIVATE-TOKEN: $ORCA_PROJECT_TOKEN" \
75+
"$ORCA_ENDPOINT/pipelines/${{ needs.orca_trigger.outputs.pipeline_id }}")
7276
status=$(echo $response | jq -r '.status')
7377
echo "Current status: $status (elapsed: ${elapsed}s)"
7478
case $status in
@@ -110,8 +114,8 @@ jobs:
110114
--silent --show-error --fail \
111115
--write-out "\n%{http_code}" \
112116
--request POST \
113-
--header "PRIVATE-TOKEN: ${{ secrets.ORCA_PROJECT_TOKEN }}" \
114-
"https://code.jlab.org/api/v4/projects/${{ secrets.ORCA_PROJECT_ID }}/pipelines/${{ needs.orca_trigger.outputs.pipeline_id }}/cancel")
117+
--header "PRIVATE-TOKEN: $ORCA_PROJECT_TOKEN" \
118+
"$ORCA_ENDPOINT/pipelines/${{ needs.orca_trigger.outputs.pipeline_id }}/cancel")
115119
http_code=$(echo "$response" | tail -n1)
116120
response_body=$(echo "$response" | sed '$d')
117121
if [ "$http_code" -eq 200 ] || [ "$http_code" -eq 201 ]; then

0 commit comments

Comments
 (0)