-
Notifications
You must be signed in to change notification settings - Fork 5
152 lines (141 loc) · 4.58 KB
/
docker.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
---
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"
docker images
- 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}"