forked from viv3kanand/tutorials
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
88 lines (81 loc) · 3.28 KB
/
.gitlab-ci.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
include:
- project: "epi2melabs/ci-templates"
file: "push-github.yaml"
variables:
OWNER: ontresearch
GIT_SUBMODULE_STRATEGY: recursive
IMAGENAME: "epi2melabs-notebook"
image: ${IMAGE}
stages:
- build
- release
build-branch:
stage: build
only:
- branches
before_script:
- apk add make bash git openssl py3-virtualenv python3
script:
- echo "Logging in to internal gitlab container registry";
- echo ${CI_BUILD_TOKEN} | docker login --username gitlab-ci-token --password-stdin ${CI_REGISTRY};
- UPSTREAM=dev PYTHON=python3 make ${IMAGENAME};
- TAG=${CI_REGISTRY}/${CI_PROJECT_PATH}/${IMAGENAME}:${CI_COMMIT_REF_NAME};
- echo "Pushing ${TAG}";
- docker tag $OWNER/${IMAGENAME}:latest ${TAG};
- docker push ${TAG};
# on dev tag/push with commit hash also
- if [[ ${CI_COMMIT_BRANCH} == 'dev' ]]; then
DEVTAG=${TAG}-${CI_COMMIT_SHORT_SHA};
echo "Pushing ${DEV_TAG}";
docker tag $OWNER/${IMAGENAME}:latest ${DEVTAG};
docker push ${DEVTAG};
HUBTAG=ontresearch/${IMAGENAME}:dev;
echo "Pushing dockerhub ${HUBTAG}";
echo ${DOCKERHUB_TOKEN} | docker login --username epi2melabs --password-stdin;
docker tag $OWNER/${IMAGENAME}:latest ${HUBTAG};
docker push ${HUBTAG};
fi
- echo "All done";
release-tag:
stage: release
only:
- tags
before_script:
- apk add make bash git openssl py3-virtualenv python3
script:
# We could pull the dev-commit tag from the repo, but instead let's
# always build from the latest tag of the upstream image on dockerhub.
# All being well this should amount to the same thing.
- echo "Logging in to internal gitlab container registry";
- echo ${DOCKERHUB_TOKEN} | docker login --username epi2melabs --password-stdin;
- export UPSTREAM=$(PYTHON=python3 make echo_latest_upstream | tail -n 1);
- echo "Upstream tag ${UPSTREAM}";
- PYTHON=python3 make ${IMAGENAME};
- HUBTAG=ontresearch/${IMAGENAME}:${CI_COMMIT_TAG};
- echo "Pushing dockerhub ${HUBTAG}";
- docker tag $OWNER/${IMAGENAME}:latest ${HUBTAG};
- docker push ${HUBTAG};
# Push repo to github
# push-github: - from template
# Rebuild notebooks and push to github blog
rebuild-notebooks:
stage: release
image: $GH_PUSH_IMAGE
script:
# install prerequisites
- apt-get update && apt-get -y install git python3-pip
- pip3 install jupyterlab
# set git
- git config --global user.email "[email protected]"
- git config --global user.name "epi2melabs-bot"
# do stuff
- jupyter nbconvert --to html tutorials/*.ipynb
# only push existing notebooks, not new ones
- git clone https://user:${BLOG_UPDATE_TOKEN}@${CI_SERVER_HOST}/${CI_PROJECT_ROOT_NAMESPACE}/labs-flexiblog.git
- cd labs-flexiblog
- cp ../tutorials/*.html site/static/notebooks
- git add -u site/static/notebooks/
- git commit -m "Updating all notebooks"
- git push origin dev
rules:
- if: '$CI_COMMIT_TAG =~ /^v[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+$/'