forked from OpenMS/OpenMS
-
Notifications
You must be signed in to change notification settings - Fork 0
173 lines (166 loc) · 7.32 KB
/
containerdeploy.yml
File metadata and controls
173 lines (166 loc) · 7.32 KB
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
name: deploy-container-images
on:
workflow_dispatch:
push:
branches:
- nightly
tags:
- "Release*"
jobs:
DeployDocker:
runs-on: ubuntu-latest
steps:
- name: Extract branch name
shell: bash
run: echo "branch=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT
id: extract_branch
- name: Define tag name
shell: bash
run: |
BRANCH=${{ steps.extract_branch.outputs.branch }}
## use latest to follow docker conventions
if [[ "$BRANCH" == "develop" || "$BRANCH" == "nightly" || "$BRANCH" == "feat/singularity" ]]
then
BRANCH="latest"
fi
## Remove release/ from release branch name (or keep the non-release name)
echo "tag=${BRANCH#release/}" >> $GITHUB_OUTPUT
id: tag_name
- name: Downcase REPO
run: echo "repo=${GITHUB_REPOSITORY,,}" >> $GITHUB_OUTPUT
id: downcase_repo
- name: Checkout repository because we need to build contrib
uses: actions/checkout@v3
with:
submodules: true
if: startsWith(steps.extract_branch.outputs.branch, 'release/')
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build contrib container using the correct submodule hash
uses: docker/build-push-action@v3
with:
push: true
context: contrib
file: contrib/dockerfiles/Dockerfile
tags: |
ghcr.io/openms/contrib:${{ steps.tag_name.outputs.tag }}
if: startsWith(steps.extract_branch.outputs.branch, 'release/')
- name: Checkout Library and Executable Dockerfiles
shell: bash # uses git bash on windows
run: |
git clone https://github.com/OpenMS/dockerfiles
cd dockerfiles
## for release, try to checkout the specific release branch in the dockerfiles repo first
if [[ "${{ steps.extract_branch.outputs.branch }}" == "release/"* ]]
then
git checkout ${{ steps.extract_branch.outputs.branch }} || git checkout master
fi
- name: Build and Push Docker Library Image
uses: docker/build-push-action@v3
with:
push: true # Will only build if this is not here
context: dockerfiles/library
build-args: |
OPENMS_TAG=latest
OPENMS_BRANCH=${{ steps.extract_branch.outputs.branch }}
tags: |
ghcr.io/${{ steps.downcase_repo.outputs.repo }}-library:${{ steps.tag_name.outputs.tag }}
- name: Build and Push Docker Tools Image
uses: docker/build-push-action@v3
with:
push: true # Will only build if this is not here
context: dockerfiles/executables
build-args: |
OPENMS_TAG=latest
OPENMS_BRANCH=${{ steps.extract_branch.outputs.branch }}
tags: |
ghcr.io/${{ steps.downcase_repo.outputs.repo }}-executables:${{ steps.tag_name.outputs.tag }}
DeploySingularity:
runs-on: ubuntu-latest
steps:
- name: Extract branch name
shell: bash
run: echo "branch=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT
id: extract_branch
- name: Define tag name
shell: bash
run: |
BRANCH=${{ steps.extract_branch.outputs.branch }}
## use latest to follow docker conventions
if [[ "$BRANCH" == "develop" || "$BRANCH" == "nightly" || "$BRANCH" == "feat/singularity" ]]
then
BRANCH="latest"
fi
## Remove release/ from release branch name
echo "tag=${BRANCH#release/}" >> $GITHUB_OUTPUT
id: tag_name
- name: Downcase REPO
shell: bash
run: echo "repo=${GITHUB_REPOSITORY,,}" >> $GITHUB_OUTPUT
id: downcase_repo
- name: Checkout repository because we need to build contrib
uses: actions/checkout@v3
with:
submodules: true
if: startsWith(steps.extract_branch.outputs.branch, 'release/')
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build contrib container using the correct submodule hash
uses: docker/build-push-action@v3
with:
push: true
context: contrib
file: contrib/dockerfiles/Dockerfile
tags: |
ghcr.io/openms/contrib:${{ steps.tag_name.outputs.tag }}
if: startsWith(steps.extract_branch.outputs.branch, 'release/')
- name: Checkout Dockerfiles
shell: bash
run: |
git clone https://github.com/OpenMS/dockerfiles
cd dockerfiles
## for release, try to checkout the specific release branch in the dockerfiles repo first
if [[ "${{ steps.extract_branch.outputs.branch }}" == "release/"* ]]
then
git checkout ${{ steps.extract_branch.outputs.branch }} || git checkout master
fi
- name: Singularity install with defaults
uses: singularityhub/install-singularity@main
with:
singularity-version: 3.11.0
- name: Install spython for conversion
shell: bash
run: |
python3 -m pip install spython
- name: Build Singularity library image
shell: bash
run: |
spython recipe dockerfiles/library/Dockerfile &> dockerfiles/library/Singularity.def
sed -E -i "s/(^From:.*:)(.*)/\1${{ steps.tag_name.outputs.tag }}/" dockerfiles/library/Singularity.def
sed -E -i "s%(^OPENMS_BRANCH=)(.*)%\1${{ steps.extract_branch.outputs.branch }}%" dockerfiles/library/Singularity.def
sed -E -i "s/(^OPENMS_TAG=)(.*)/\1${{ steps.tag_name.outputs.tag }}/" dockerfiles/library/Singularity.def
cat dockerfiles/library/Singularity.def
sudo singularity build library.sif dockerfiles/library/Singularity.def
- name: Build Singularity tools image
shell: bash
run: |
spython recipe dockerfiles/executables/Dockerfile &> dockerfiles/executables/Singularity.def
sed -E -i "s%^From:.*%From: $(pwd)/library.sif%" dockerfiles/executables/Singularity.def
sed -E -i "s/^Bootstrap:.*/Bootstrap: localimage/" dockerfiles/executables/Singularity.def
cat dockerfiles/executables/Singularity.def
sudo singularity build executables.sif dockerfiles/executables/Singularity.def
- name: Upload images to ghcr.io
shell: bash
run: |
echo ${{ secrets.GITHUB_TOKEN }} | singularity remote login -u jpfeuffer --password-stdin oras://ghcr.io
singularity push library.sif oras://ghcr.io/${{ steps.downcase_repo.outputs.repo }}-library-sif:${{ steps.tag_name.outputs.tag }}
echo ${{ secrets.GITHUB_TOKEN }} | singularity remote login -u jpfeuffer --password-stdin oras://ghcr.io
singularity push executables.sif oras://ghcr.io/${{ steps.downcase_repo.outputs.repo }}-executables-sif:${{ steps.tag_name.outputs.tag }}