tutorial-datasets.csv
: Remove t1.nii.gz from seg zip
#79
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "Run batch_single_subject.sh" | |
# The tl;dr purpose of this workflow is to: | |
# - A) Run all of the commands in the SCT Course | |
# - B) If the workflow is run manually, then take the output files and package them into tutorial-specific datasets. | |
# | |
# In-depth explanation: | |
# Most of SCT's tutorials depend on files generated by previous steps. (For example, 'sct_register_to_template' | |
# depends on the segmented spinal cord image file generated by `sct_deepseg`. This creates a dilemma: If we want | |
# SCT's tutorials to stand alone, we need to provide these intermediate files. But, if we want to run the tutorials | |
# start to finish in a sequence (e.g. during the SCT Course), it would be confusing if the intermediate files | |
# were already there. | |
# | |
# The solution is to only store the minimally-necessary files in the repository, then generate the intermediate files | |
# using this workflow. That way, we can provide 2 different downloads: | |
# - 'sct_course_data.zip': Files required to run the SCT course from start to finish. | |
# - 'registration.zip', 'segmentation.zip', etc.: Files required by individual tutorials. | |
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
workflow_dispatch: | |
inputs: | |
release_title: | |
description: 'Release title (e.g. rYYYYMMDD)' | |
required: true | |
jobs: | |
run-course-script: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout spinalcordtoolbox | |
uses: actions/checkout@v4 | |
with: | |
repository: spinalcordtoolbox/spinalcordtoolbox | |
path: spinalcordtoolbox | |
# install_sct edits ~/.bashrc, but those environment changes don't get passed to subsequent steps in GH Actions. | |
# So, we filter through the .bashrc and pass the values to $GITHUB_ENV and $GITHUB_PATH. | |
# Relevant documentation: https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#environment-files | |
# This workaround should be replaced by https://github.com/spinalcordtoolbox/spinalcordtoolbox/pull/3198#discussion_r568225392 | |
- name: Install spinalcordtoolbox | |
run: | | |
cd spinalcordtoolbox | |
./install_sct -iy | |
cat ~/.bashrc | grep "export SCT_DIR" | cut -d " " -f 2 >> $GITHUB_ENV | |
cat ~/.bashrc | grep "export MPLBACKEND" | cut -d " " -f 2 >> $GITHUB_ENV | |
cat ~/.bashrc | grep "export PATH" | grep -o "/.*" | cut -d ':' -f 1 >> $GITHUB_PATH | |
- name: "Checkout '${{ github.event.repository.name }}'" | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ env.GITHUB_SHA }} | |
path: ${{ github.event.repository.name }} | |
- name: Run batch_single_subject.sh to generate intermediate files | |
run: | | |
cd "${{ github.event.repository.name }}/single_subject" | |
./batch_single_subject.sh | |
- name: "Package data into tutorial-specific .zip files" | |
run: | | |
cd ${{ github.event.repository.name }} | |
awk -F, '{ print $1,$2 }' tutorial-datasets.csv | xargs -l zip -ur | |
- uses: ncipollo/release-action@v1 | |
name: Create release ('${{ github.event.inputs.release_title }}') | |
id: create_release | |
with: | |
tag: ${{ github.event.inputs.release_title }} | |
commit: ${{ env.GITHUB_SHA }} | |
token: ${{ secrets.GITHUB_TOKEN }} | |
# Only create release if workflow is run manually. (This allows the workflow to double as a PR test.) | |
if: github.event_name == 'workflow_dispatch' | |
- uses: xresloader/upload-to-github-release@v1 | |
name: Attach .zip files to newly-created release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
file: "${{ github.event.repository.name }}/*.zip" | |
draft: false | |
tag_name: ${{ github.event.inputs.release_title }} | |
release_id: ${{ steps.create_release.outputs.id }} | |
# Only attach to release if workflow is run manually. (This allows the workflow to double as a PR test.) | |
if: github.event_name == 'workflow_dispatch' |