forked from topocm/topocm_content
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
120 lines (104 loc) · 2.99 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
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
image: topocourse/topocourse
stages:
- execute
- build
- deploy
execute_ipynbs:
stage: execute
before_script:
- pip install ruamel.yaml git+https://gitlab.kwant-project.org/anton-akhmerov/publist.git
script:
- export PYTHONPATH=$PYTHONPATH:${PWD}/code
- export OPENBLAS_NUM_THREADS=1 OMP_NUM_THREADS=1 MKL_NUM_THREADS=1 MKL_DYNAMIC=FALSE
- export MARKDOWN=generated/markdown
- mkdir -p $MARKDOWN
- cp -r src/* $MARKDOWN
- python scripts/preprocess_markdown.py
- export WITH_OUTPUT=generated/with_output
- cp -r data $WITH_OUTPUT
- cp -r $MARKDOWN/* $WITH_OUTPUT
- find $WITH_OUTPUT -name '*.md' | parallel --delay 3 --jobs 32 notedown -o --run --timeout -1 --match fenced
- rm -rf $WITH_OUTPUT/data
artifacts:
paths:
- generated/with_output
expire_in: 7d
mirror to github:
stage: execute
allow_failure: true
only:
- branches@qt/topocm
variables:
REPOS: "[email protected]:topocm/topocm_content.git"
before_script:
- HOSTS=$(for REPO in $REPOS; do echo ${REPO%:*} | cut -d'@' -f2; done)
- mkdir ~/.ssh && chmod 700 ~/.ssh
- for HOST in $HOSTS; do ssh-keyscan $HOST >> ~/.ssh/known_hosts; done
- echo "$PUSH_KEY" > ~/.ssh/id_rsa && chmod 600 ~/.ssh/id_rsa
after_script:
- rm -rf ~/.ssh
script:
- ORIGIN_URL=$(git config --get remote.origin.url)
- cd $(mktemp -d); git clone --bare $ORIGIN_URL .
- for REPO in $REPOS; do git push --mirror $REPO; done
edx archive:
stage: build
before_script:
- pip install ruamel.yaml
script: ./scripts/converter.py ./generated/with_output
artifacts:
paths:
- generated/import_to_edx.tar.gz
- generated/html/edx
expire_in: 7d
pelican website:
stage: build
variables:
DEST: "generated/html"
before_script:
- pip install ruamel.yaml
script:
- python scripts/converter_pelican.py
- pelican -o $DEST/ -s website_assets/pelicanconf.py generated/pelican_content
- cp -r generated/with_output ${DEST}/notebooks
artifacts:
paths:
- generated/html
expire_in: 1d
ocw website:
stage: build
before_script:
- pip install ruamel.yaml
script:
- python scripts/converter_ocw.py
- mv website_assets/iframes.txt generated/html/ocw
artifacts:
paths:
- generated/html/ocw
expire_in: 1d
.upload_website: &upload_website
stage: deploy
before_script:
- mkdir -p ~/.ssh && ssh-keyscan tnw-tn1.tudelft.net >> ~/.ssh/known_hosts
- echo $WEBSITE_KEY | base64 -d > ~/.ssh/id_rsa && chmod 600 ~/.ssh/id_rsa
script:
- "rsync -ravz --delete generated/html/* [email protected]:"
- "rsync -ravz --delete website_assets/static [email protected]:"
after_script:
- rm -rf ~/.ssh
upload test website:
<<: *upload_website
environment: test
only:
- branches@qt/topocm
except:
- master@qt/topocm
variables:
USER: topocm-test
upload main website:
<<: *upload_website
environment: published
only:
- master@qt/topocm
variables:
USER: topocm