File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change 30
30
- name : Check Action was successfully dispatched
31
31
id : dispatched
32
32
run : |
33
- set -x
34
33
START=${{ steps.start.outputs.start_time }}
35
- RUN_ID=$(curl -H "Accept: application/vnd.github+json" \
34
+ RUN_ID=$(curl -s - H "Accept: application/vnd.github+json" \
36
35
'https://api.github.com/repos/miykael/nipype_tutorial/actions/runs?created=>'${START}'&per_page=1' \
37
36
| jq -r '.workflow_runs[0].id')
38
37
@@ -42,13 +41,12 @@ jobs:
42
41
- name : Check if action completed
43
42
timeout-minutes : 120
44
43
run : |
45
- set -x
46
44
RUN_ID=${{ steps.dispatched.outputs.run_id }}
47
45
while :
48
46
do
49
47
TIMESTAMP=$(date +'%Y-%m-%dT%H:%M:%S%z')
50
48
# check status every 5 minutes
51
- STATUS=$(curl -H "Accept: application/vnd.github+json" \
49
+ STATUS=$(curl -s - H "Accept: application/vnd.github+json" \
52
50
https://api.github.com/repos/miykael/nipype_tutorial/actions/runs/${RUN_ID} \
53
51
| jq -r '.conclusion')
54
52
case $STATUS in
65
63
sleep 300
66
64
esac
67
65
done
66
+ - name : Cancel ongoing run if cancelled or failed
67
+ if : ${{ failure() || cancelled() }}
68
+ run : |
69
+ set -x
70
+ RUN_ID=${{ steps.dispatched.outputs.run_id }}
71
+ echo "Something went wrong, cancelling dispatched run"
72
+ curl -s -X POST \
73
+ -H "Accept: application/vnd.github+json" \
74
+ -H "Authorization: Bearer ${{ secrets.TUTORIAL_ACCESS_TOKEN }}" \
75
+ https://api.github.com/repos/miykael/nipype_tutorial/actions/runs/${RUN_ID}/cancel
You can’t perform that action at this time.
0 commit comments