1+ name : QuantMS Containers Build and Sync
2+
3+ on :
4+ push :
5+ branches : [ "main" ]
6+ pull_request :
7+ branches : [ "main" ]
8+ paths :
9+ - ' diann-*/Dockerfile'
10+ - ' .github/workflows/**'
11+ release :
12+ types : [published]
13+ workflow_dispatch :
14+ inputs :
15+ push_images :
16+ description : ' Push images to registry'
17+ required : false
18+ default : true
19+ type : ' boolean'
20+ push_release :
21+ description : ' Push as release version'
22+ required : false
23+ default : false
24+ type : boolean
25+
26+ jobs :
27+ build-diann :
28+ name : Build and Push DiaNN Docker Images
29+ runs-on : ubuntu-latest
30+ permissions :
31+ contents : read
32+ packages : write
33+
34+ env :
35+ RETRY_TIMES : 3
36+ RETRY_DELAY : 30
37+
38+ steps :
39+ - name : Checkout repository
40+ uses : actions/checkout@v4
41+
42+ - name : Set up Docker Buildx
43+ uses : docker/setup-buildx-action@v3
44+
45+ - name : Log in to GitHub Container Registry
46+ uses : docker/login-action@v3
47+ with :
48+ registry : ghcr.io
49+ username : ${{ github.actor }}
50+ password : ${{ secrets.GHCR_TOKEN }}
51+
52+ - name : Extract metadata for Docker
53+ id : meta
54+ uses : docker/metadata-action@v5
55+ with :
56+ images : ghcr.io/bigbio/diann
57+ tags : |
58+ type=raw,value=latest,enable={{is_default_branch}}
59+ type=raw,value={{date 'YYYY.MM.DD'}}
60+
61+ - name : Set date tag
62+ id : date
63+ run : echo "DATE_TAG=$(date +'%Y.%m.%d')" >> $GITHUB_OUTPUT
64+
65+ - name : Build and Push DiaNN 2.1.0 image (Latest)
66+ uses : docker/build-push-action@v5
67+ with :
68+ context : ./diann-2.1.0
69+ push : ${{ (github.event.inputs.push_images == true || github.event.inputs.push_images == '') }}
70+ tags : |
71+ ghcr.io/bigbio/diann:2.1.0
72+ ghcr.io/bigbio/diann:latest
73+ cache-from : type=gha
74+ cache-to : type=gha,mode=max
75+ provenance : false
76+
77+ - name : Set up Singularity
78+ if : ${{ (github.event.inputs.push_images == true || github.event.inputs.push_images == '') }}
79+ uses : eWaterCycle/setup-singularity@v7
80+ with :
81+ singularity-version : 3.8.7
82+
83+ - name : Pull Docker image for Singularity conversion
84+ if : ${{ (github.event.inputs.push_images == true || github.event.inputs.push_images == '') }}
85+ run : |
86+ # Pull the Docker image from GitHub Container Registry
87+ docker pull ghcr.io/bigbio/diann:2.1.0
88+ # Save the Docker image to a tar file
89+ docker save ghcr.io/bigbio/diann:2.1.0 -o diann-2.1.0.tar
90+
91+ - name : Convert Docker image to Singularity
92+ if : ${{ (github.event.inputs.push_images == true || github.event.inputs.push_images == '') }}
93+ run : |
94+ # Convert Docker tar to Singularity SIF
95+ singularity build diann-2.1.0.sif docker-archive://diann-2.1.0.tar
96+ # Verify the SIF file exists
97+ ls -la diann-2.1.0.sif
98+
99+ - name : Login and Deploy Container
100+ if : (github.event_name != 'pull_request')
101+ env :
102+ IS_RELEASE : ${{ github.event_name == 'release' }}
103+ run : |
104+ echo ${{ secrets.GHCR_TOKEN }} | singularity remote login -u ${{ secrets.GHCR_USERNAME }} --password-stdin oras://ghcr.io
105+
106+ # Push with version tag
107+ singularity push diann-2.1.0.sif oras://bigbio/diann-sif:2.1.0
108+
109+ # Push with date tag
110+ singularity push diann-2.1.0.sif oras://bigbio/diann-sif:2.1.0-${{ steps.date.outputs.DATE_TAG }}
111+
112+ # If this is a release event, also tag as latest
113+ if [[ "${{ env.IS_RELEASE }}" == "true" || "${{ github.event_name }}" == "release" ]]; then
114+ singularity push diann-2.1.0.sif oras://bigbio/diann-sif:latest
115+ fi
116+
117+ - name : Notify on success
118+ if : success()
119+ run : |
120+ echo "::notice::Successfully built and pushed DiaNN Docker and Singularity images to ghcr.io/bigbio"
121+
122+ - name : Notify on failure
123+ if : failure()
124+ run : |
125+ echo "::error::Failed to build or push DiaNN images. Check the logs for details."
126+
127+ sync-openms :
128+ name : Sync OpenMS Containers
129+ needs : build-diann
130+ runs-on : ubuntu-latest
131+ permissions :
132+ contents : read
133+ packages : write
134+
135+ steps :
136+ - name : Checkout repository
137+ uses : actions/checkout@v4
138+
139+ - name : Set up Docker Buildx
140+ uses : docker/setup-buildx-action@v3
141+
142+ - name : Log in to GitHub Container Registry
143+ uses : docker/login-action@v3
144+ with :
145+ registry : ghcr.io
146+ username : ${{ github.actor }}
147+ password : ${{ secrets.GHCR_TOKEN }}
148+
149+ - name : Set date tag
150+ id : date
151+ run : echo "DATE_TAG=$(date +'%Y.%m.%d')" >> $GITHUB_OUTPUT
152+
153+ - name : Pull OpenMS Docker container
154+ id : pull_docker
155+ uses : nick-fields/retry@v2
156+ with :
157+ timeout_minutes : 10
158+ max_attempts : 3
159+ retry_wait_seconds : 30
160+ command : docker pull ghcr.io/openms/openms-tools-thirdparty:latest
161+
162+ - name : Tag and push OpenMS Docker container
163+ if : steps.pull_docker.outcome == 'success'
164+ run : |
165+ # Set container names
166+ SOURCE_CONTAINER="ghcr.io/openms/openms-tools-thirdparty:latest"
167+ TARGET_CONTAINER="ghcr.io/bigbio/openms-tools-thirdparty:${{ steps.date.outputs.DATE_TAG }}"
168+
169+ echo "Tagging as $TARGET_CONTAINER"
170+ docker tag $SOURCE_CONTAINER $TARGET_CONTAINER
171+
172+ echo "Pushing $TARGET_CONTAINER"
173+ docker push $TARGET_CONTAINER || {
174+ echo "Failed to push $TARGET_CONTAINER, retrying..."
175+ sleep 30
176+ docker push $TARGET_CONTAINER
177+ }
178+
179+ # If this is a release push or a GitHub release event, also tag as latest
180+ if [[ "${{ github.event.inputs.push_release }}" == "true" || "${{ github.event_name }}" == "release" ]]; then
181+ LATEST_IMAGE="ghcr.io/bigbio/openms-tools-thirdparty:latest"
182+ docker tag $SOURCE_CONTAINER $LATEST_IMAGE
183+ docker push $LATEST_IMAGE || {
184+ echo "Failed to push $LATEST_IMAGE, retrying..."
185+ sleep 30
186+ docker push $LATEST_IMAGE
187+ }
188+ echo "Pushed release version as $LATEST_IMAGE"
189+ fi
190+
191+ - name : Set up Singularity
192+ if : success()
193+ uses : eWaterCycle/setup-singularity@v7
194+ with :
195+ singularity-version : 3.8.7
196+
197+ - name : Configure Singularity for GitHub Container Registry
198+ if : success()
199+ run : |
200+ # Create Singularity remote endpoint for GitHub Container Registry
201+ singularity remote add --no-login GithubContainer oras://ghcr.io
202+
203+ # Login to GitHub Container Registry
204+ echo "${{ secrets.GHCR_TOKEN }}" | singularity remote login -u ${{ secrets.GHCR_USERNAME }} --password-stdin GithubContainer
205+
206+ - name : Pull OpenMS SIF container
207+ id : pull_sif
208+ if : success()
209+ uses : nick-fields/retry@v2
210+ with :
211+ timeout_minutes : 15
212+ max_attempts : 3
213+ retry_wait_seconds : 60
214+ command : singularity pull --force openms-tools-thirdparty.sif oras://ghcr.io/openms/openms-tools-thirdparty-sif:latest
215+
216+ - name : Login and Push OpenMS SIF container
217+ if : steps.pull_sif.outcome == 'success'
218+ env :
219+ keepgoing : true
220+ run : |
221+ # Login to GitHub Container Registry
222+ echo ${{ secrets.GHCR_TOKEN }} | singularity remote login -u ${{ secrets.GHCR_USERNAME }} --password-stdin oras://ghcr.io
223+
224+ # Set SIF paths and push with date tag
225+ echo "Pushing OpenMS SIF with date tag"
226+ singularity push openms-tools-thirdparty.sif oras://bigbio/openms-tools-thirdparty-sif:${{ steps.date.outputs.DATE_TAG }} || {
227+ echo "Failed to push with date tag, retrying..."
228+ sleep 60
229+ singularity push openms-tools-thirdparty.sif oras://bigbio/openms-tools-thirdparty-sif:${{ steps.date.outputs.DATE_TAG }}
230+ }
231+
232+ # If this is a release push or a GitHub release event, also tag as latest
233+ if [[ "${{ github.event.inputs.push_release }}" == "true" || "${{ github.event_name }}" == "release" ]]; then
234+ echo "Pushing OpenMS SIF as latest"
235+ singularity push openms-tools-thirdparty.sif oras://bigbio/openms-tools-thirdparty-sif:latest || {
236+ echo "Failed to push as latest, retrying..."
237+ sleep 60
238+ singularity push openms-tools-thirdparty.sif oras://bigbio/openms-tools-thirdparty-sif:latest
239+ }
240+ fi
241+
242+ - name : Notify on success
243+ if : success()
244+ run : |
245+ echo "::notice::Successfully synced OpenMS containers to BigBio repositories"
246+
247+ - name : Notify on failure
248+ if : failure()
249+ run : |
250+ echo "::error::Failed to sync OpenMS containers. Check the logs for details."
0 commit comments