forked from OpenMS/OpenMS
-
Notifications
You must be signed in to change notification settings - Fork 0
138 lines (131 loc) · 5.88 KB
/
Copy pathcontainerdeploy.yml
File metadata and controls
138 lines (131 loc) · 5.88 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
name: deploy-container-images
on:
workflow_dispatch:
push:
branches:
- nightly
- '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 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: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- 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 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 }}