|
9 | 9 | tutorial:
|
10 | 10 | runs-on: ubuntu-latest
|
11 | 11 | env:
|
12 |
| - BRANCH_NAME: ${{ github.head_ref || github.ref_name }} |
| 12 | + BRANCH_NAME: ${{ github.ref_name }} |
13 | 13 | steps:
|
14 | 14 | - name: Start time
|
15 | 15 | id: start
|
16 | 16 | run: echo "::set-output name=start_time::$(date +'%Y-%m-%dT%H:%M:%S%z')"
|
17 | 17 | - name: Trigger Nipype tutorial Github Action
|
18 | 18 | run: |
|
| 19 | + set -x |
19 | 20 | curl -X POST \
|
20 | 21 | -H "Authorization: Bearer ${{ secrets.TUTORIAL_ACCESS_TOKEN }}" \
|
21 | 22 | -H "Accept: application/vnd.github+json" \
|
22 | 23 | https://api.github.com/repos/miykael/nipype_tutorial/actions/workflows/testing.yml/dispatches \
|
23 |
| - -d '{"nipype_branch": "'${BRANCH_NAME:4}'"}' |
| 24 | + -d '{"ref": "master", "inputs": {"nipype_branch": "'${BRANCH_NAME}'"}}' |
| 25 | + sleep 10 |
24 | 26 | - name: Check Action was successfully dispatched
|
25 | 27 | id: dispatched
|
26 | 28 | run: |
|
27 |
| - RUN_ID=$(curl -X POST \ |
28 |
| - -H "Accept: application/vnd.github+json" \ |
29 |
| - "https://api.github.com/repos/miykael/nipype_tutorial/actions/runs?created=>${{ steps.start.outputs.start_time }}&per_page=1" \ |
| 29 | + set -x |
| 30 | + START=${{ steps.start.outputs.start_time }} |
| 31 | + RUN_ID=$(curl -H "Accept: application/vnd.github+json" \ |
| 32 | + 'https://api.github.com/repos/miykael/nipype_tutorial/actions/runs?created=>'${START}'&per_page=1' \ |
30 | 33 | | jq -r '.workflow_runs[0].id')
|
31 | 34 |
|
32 | 35 | # fail if not extracted
|
33 | 36 | [[ -n $RUN_ID ]] || exit 1
|
34 |
| - echo "::set-output name=run_id::$RUN_ID"" |
| 37 | + echo "::set-output name=run_id::$RUN_ID" |
35 | 38 | - name: Check if action completed
|
36 |
| - timeout-minutes: 60 |
| 39 | + timeout-minutes: 120 |
37 | 40 | run: |
|
| 41 | + set -x |
| 42 | + RUN_ID=${{ steps.dispatched.outputs.run_id }} |
38 | 43 | while :
|
39 | 44 | do
|
40 | 45 | TIMESTAMP=$(date +'%Y-%m-%dT%H:%M:%S%z')
|
41 | 46 | # check status every 5 minutes
|
42 | 47 | STATUS=$(curl -H "Accept: application/vnd.github+json" \
|
43 |
| - "https://api.github.com/repos/miykael/nipype_tutorial/actions/runs/${{ steps.dispatched.outputs.run_id }}" \ |
| 48 | + https://api.github.com/repos/miykael/nipype_tutorial/actions/runs/${RUN_ID} \ |
44 | 49 | | jq -r '.conclusion')
|
45 | 50 | case $STATUS in
|
46 | 51 | success)
|
47 |
| - echo "[$TIMESTAMP] Tutorial run ${{ steps.dispatched.outputs.run_id }} completed successfully." |
| 52 | + echo "[$TIMESTAMP] Tutorial run $RUN_ID completed successfully." |
48 | 53 | exit 0
|
49 |
| - ;; |
| 54 | + ;; |
50 | 55 | failure)
|
51 |
| - echo "[$TIMESTAMP] Tutorial run ${{ steps.dispatched.outputs.run_id }} failed." |
| 56 | + echo "[$TIMESTAMP] Tutorial run $RUN_ID failed." |
52 | 57 | exit 1
|
53 |
| - ;; |
| 58 | + ;; |
54 | 59 | *)
|
55 | 60 | echo "[$TIMESTAMP] Conclusion ($STATUS) is not yet complete"
|
56 | 61 | sleep 300
|
| 62 | + esac |
57 | 63 | done
|
0 commit comments