Skip to content

MAINT: Add github action to trigger tutorials for release branches #3504

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 20, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
MAINT: Add github action to trigger tutorials
  • Loading branch information
mgxd committed Sep 2, 2022
commit 2b15c0b422d8a6b51a8847eb2201898eac81997b
57 changes: 57 additions & 0 deletions .github/workflows/tutorials.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Test tutorials

on:
push:
branches:
- 'rel/*'

jobs:
tutorial:
runs-on: ubuntu-latest
env:
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
steps:
- name: Start time
id: start
run: echo "::set-output name=start_time::$(date +'%Y-%m-%dT%H:%M:%S%z')"
- name: Trigger Nipype tutorial Github Action
run: |
curl -X POST \
-H "Authorization: Bearer ${{ secrets.TUTORIAL_ACCESS_TOKEN }}" \
-H "Accept: application/vnd.github+json" \
https://api.github.com/repos/miykael/nipype_tutorial/actions/workflows/testing.yml/dispatches \
-d '{"nipype_branch": "'${BRANCH_NAME:4}'"}'
- name: Check Action was successfully dispatched
id: dispatched
run: |
RUN_ID=$(curl -X POST \
-H "Accept: application/vnd.github+json" \
"https://api.github.com/repos/miykael/nipype_tutorial/actions/runs?created=>${{ steps.start.outputs.start_time }}&per_page=1" \
| jq -r '.workflow_runs[0].id')

# fail if not extracted
[[ -n $RUN_ID ]] || exit 1
echo "::set-output name=run_id::$RUN_ID""
- name: Check if action completed
timeout-minutes: 60
run: |
while :
do
TIMESTAMP=$(date +'%Y-%m-%dT%H:%M:%S%z')
# check status every 5 minutes
STATUS=$(curl -H "Accept: application/vnd.github+json" \
"https://api.github.com/repos/miykael/nipype_tutorial/actions/runs/${{ steps.dispatched.outputs.run_id }}" \
| jq -r '.conclusion')
case $STATUS in
success)
echo "[$TIMESTAMP] Tutorial run ${{ steps.dispatched.outputs.run_id }} completed successfully."
exit 0
;;
failure)
echo "[$TIMESTAMP] Tutorial run ${{ steps.dispatched.outputs.run_id }} failed."
exit 1
;;
*)
echo "[$TIMESTAMP] Conclusion ($STATUS) is not yet complete"
sleep 300
done