set pybids config (#174) #94
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: docker | |
on: | |
push: | |
branches: ['main'] | |
tags: ['*'] | |
pull_request: | |
branches: ['*'] | |
paths: | |
- 'Dockerfile' | |
- 'requirements.txt' | |
- '.github/workflows/docker.yml' | |
- 'tools/*' | |
release: | |
types: [published] | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
permissions: | |
contents: read | |
env: | |
USER_NAME: bids | |
REPO_NAME: giga_connectome | |
DATA: /home/runner/work/giga_connectome/giga_connectome/giga_connectome/data/test_data | |
IMAGE: /home/runner/work/giga_connectome/giga_connectome/docker | |
jobs: | |
download-test-data: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: actions/cache@v4 | |
id: cache | |
with: | |
path: ${{ env.DATA }} | |
key: data | |
- if: ${{ steps.cache.outputs.cache-hit != 'true' }} | |
uses: actions/setup-python@v5 | |
- if: ${{ steps.cache.outputs.cache-hit != 'true' }} | |
name: Download fmriprep derivative of ds000017 | |
run: | | |
pip install tox | |
tox -e test_data | |
docker-build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Build the Docker image | |
run: | | |
docker build . --file Dockerfile --tag ${{env.USER_NAME}}/${{env.REPO_NAME}} | |
mkdir -p ${{ env.IMAGE }} | |
docker save "${{env.USER_NAME}}/${{env.REPO_NAME}}" > "${{ env.IMAGE }}/image.tar" | |
- name: Check image size and version | |
run: | | |
docker images | |
docker run --rm ${{env.USER_NAME}}/${{env.REPO_NAME}} --version | |
- name: Upload docker artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: docker | |
path: ${{ env.IMAGE }} | |
docker-run: | |
runs-on: ubuntu-latest | |
needs: [download-test-data, docker-build] | |
strategy: | |
matrix: | |
atlas: ['Schaefer2018', 'MIST', 'DiFuMo', 'HarvardOxfordCortical', 'HarvardOxfordCorticalSymmetricSplit', 'HarvardOxfordSubcortical'] | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Restore docker image | |
uses: actions/download-artifact@v4 | |
with: | |
name: docker | |
path: ${{ env.IMAGE }} | |
- name: Restore cached data ds000017 | |
uses: actions/cache/restore@v4 | |
with: | |
path: ${{ env.DATA }} | |
key: data | |
- name: Test the Docker image | |
run: | | |
docker load -i ${{ env.IMAGE }}/image.tar | |
docker run --rm \ | |
-v ${{ env.DATA }}:/test_data \ | |
-v ./outputs:/outputs \ | |
-v ./outputs/atlases:/atlases \ | |
${{env.USER_NAME}}/${{env.REPO_NAME}} \ | |
/test_data/ds000017-fmriprep22.0.1-downsampled-nosurface \ | |
/outputs \ | |
participant \ | |
-a /atlases \ | |
--atlas ${{ matrix.atlas }} \ | |
--participant_label 1 \ | |
--reindex-bids | |
- name: Upload output artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: connectome_${{ matrix.atlas }} | |
path: ./outputs/ | |
docker-push: | |
runs-on: ubuntu-latest | |
needs: [docker-run] | |
defaults: | |
run: | |
shell: bash -el {0} | |
if: ${{ github.ref == 'refs/heads/main' || github.ref_type == 'tag' }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Restore docker image | |
uses: actions/download-artifact@v4 | |
with: | |
name: docker | |
path: ${{ env.IMAGE }} | |
- name: Log in to Docker Hub | |
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Load image | |
run: docker load -i ${{ env.IMAGE }}/image.tar | |
- name: Push unstable to dockerhub on tags or on main | |
run: | | |
echo "Pushing unstable versions to DockerHub" | |
unstable="${{env.USER_NAME}}/${{env.REPO_NAME}}:unstable" | |
docker tag "${{env.USER_NAME}}/${{env.REPO_NAME}}" "${unstable}" | |
docker push "${unstable}" | |
- name: Push stable release to dockerhub on tags only | |
if: ${{ github.ref_type == 'tag' }} | |
run: | | |
echo "Pushing stable and latest versions to DockerHub for latest and ${{ github.ref_name }}" | |
unstable="${{env.USER_NAME}}/${{env.REPO_NAME}}:unstable" | |
latest="${{env.USER_NAME}}/${{env.REPO_NAME}}:latest" | |
docker tag "${unstable}" "${latest}" | |
docker push "${latest}" | |
tagged_release="${{env.USER_NAME}}/${{env.REPO_NAME}}:${{ github.ref_name }}" | |
docker tag "${unstable}" "${tagged_release}" | |
docker push "${tagged_release}" |