-
Notifications
You must be signed in to change notification settings - Fork 12
174 lines (162 loc) · 8.01 KB
/
deploy.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
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
174
name: Deploy
on:
schedule:
# Run at 7am every day
# - cron: '0 7 * * *'
# Run at 2am every Monday
- cron: "0 2 * * 1"
workflow_dispatch:
jobs:
deploy:
runs-on: ubuntu-latest
env:
SSH: ssh -o StrictHostKeyChecking=no -o TCPKeepAlive=yes -o ServerAliveInterval=150 -i ~/.ssh/demo.key [email protected]
VERSION: sumac
LMS_HOST: sumac.demo.edly.io
TUTOR: ~/.local/bin/tutor
steps:
- name: Configure SSH
run: |
mkdir -p ~/.ssh/
echo "$SSH_KEY" > ~/.ssh/demo.key
chmod 600 ~/.ssh/demo.key
env:
SSH_KEY: ${{ secrets.DEMO_SSH_KEY }}
- name: Upgrade python requirements
# Older versions of pip are affected by this issue which prevents us from
# installing in editable mode in ~/.local:
# https://github.com/pypa/pip/issues/7953
run: |
$SSH "#! /bin/bash -e
pip install --user --upgrade pip setuptools
"
# Server system dependencies, to be run separately
# apt update && apt install -y python3-pip
- name: Install dependencies, tutor and plugins (from source)
# Pending:
run: |
$SSH "#! /bin/bash -e
pip install --user --upgrade --src=~/apps/openedx/src --editable git+https://github.com/overhangio/tutor.git@$VERSION#egg=tutor
pip install --user --upgrade --src=~/apps/openedx/src --editable git+https://github.com/overhangio/tutor-mfe.git@$VERSION#egg=tutor-mfe
pip install --user --upgrade --src=~/apps/openedx/src --editable git+https://github.com/overhangio/tutor-indigo.git@$VERSION#egg=tutor-indigo
pip install --user --upgrade --src=~/apps/openedx/src --editable git+https://github.com/overhangio/tutor-discovery.git@$VERSION#egg=tutor-discovery
pip install --user --upgrade --src=~/apps/openedx/src --editable git+https://github.com/overhangio/tutor-credentials.git@$VERSION#egg=tutor-credentials
pip install --user --upgrade --src=~/apps/openedx/src --editable git+https://github.com/overhangio/tutor-ecommerce.git@$VERSION#egg=tutor-ecommerce
pip install --user --upgrade --src=~/apps/openedx/src --editable git+https://github.com/overhangio/tutor-forum.git@$VERSION#egg=tutor-forum
pip install --user --upgrade --src=~/apps/openedx/src --editable git+https://github.com/overhangio/tutor-minio.git@$VERSION#egg=tutor-minio
pip install --user --upgrade --src=~/apps/openedx/src --editable git+https://github.com/overhangio/tutor-notes.git@$VERSION#egg=tutor-notes
pip install --user --upgrade --src=~/apps/openedx/src --editable git+https://github.com/overhangio/tutor-xqueue.git@$VERSION#egg=tutor-xqueue
pip install --user --upgrade --src=~/apps/openedx/src --editable git+https://github.com/overhangio/tutor-android.git@$VERSION#egg=tutor-android
pip install --user --upgrade --src=~/apps/openedx/src --editable git+https://github.com/overhangio/tutor-jupyter.git@$VERSION#egg=tutor-jupyter
pip install --user --upgrade --src=~/apps/openedx/src --editable git+https://github.com/overhangio/tutor-webui.git@$VERSION#egg=tutor-webui
pip install --user --upgrade --src=~/apps/openedx/src --editable git+https://github.com/openedx/[email protected]#egg=tutor-contrib-aspects
pip install --user --upgrade --src=~/apps/openedx/src --editable git+https://github.com/eduNEXT/tutor-contrib-codejail.git@$VERSION#egg=tutor-contrib-codejail
"
# Backup
- name: Backup data
run: |
$SSH "#! /bin/bash -e
mkdir -p ~/apps/openedx/backup
if [ -d ~/.local/share/tutor/data/caddy ]
then
echo "Backing up caddy data"
sudo cp -r ~/.local/share/tutor/data/caddy ~/apps/openedx/backup/
else
echo "No caddy data to backup"
fi
"
# Clear
- name: Clear existing platform
run: |
$SSH "#! /bin/bash -e
if [ -d ~/.local/share/tutor/env ]
then
echo "Stopping tutor containers"
$TUTOR local stop
else
echo "No running tutor container"
fi
sudo rm -rf ~/.local/share/tutor
docker container prune --force
"
# Restore
- name: Restore some data
run: |
$SSH "#! /bin/bash -e
mkdir -p ~/.local/share/tutor/data/
if [ -d ~/apps/openedx/backup/caddy ]
then
echo "Restoring caddy backup data"
sudo cp -r ~/apps/openedx/backup/caddy ~/.local/share/tutor/data/
else
echo "No caddy backup data to restore"
fi
"
# Configure
- name: Enable plugins
# missing plugins: forum (forum is temporarily disabled until forum_v2 related PRs are merged)
run: $SSH "$TUTOR plugins enable indigo mfe aspects codejail credentials discovery ecommerce minio notes xqueue android jupyter webui"
- name: Configure tutor settings
run: |
$SSH "#! /bin/bash -e
$TUTOR config save \
--set LMS_HOST=$LMS_HOST \
--set CMS_HOST=studio.$LMS_HOST \
--set ENABLE_HTTPS=true \
--set PLATFORM_NAME='Open edX Sumac Demo'
"
- name: Configure xqueue grader password
run: |
$SSH "$TUTOR config save --set XQUEUE_AUTH_PASSWORD=xqueuepassword"
- name: Configure Jupyter LTI Password
run: |
$SSH "$TUTOR config save --set JUPYTER_LTI_CLIENT_SECRET=jupyter-lti-password"
# Build
- name: Build Docker images
run: |
$SSH "#! /bin/bash -e
$TUTOR images build all
"
- name: Initialize codejail
run: $SSH "$TUTOR local do init --limit=codejail"
- name: Configure Aspects
run: |
$SSH "$TUTOR config save --set ASPECTS_ENABLE_PII=true"
- name: Launch
run: $SSH "$TUTOR local launch --non-interactive"
# Provision
# - name: "Provision: Set theme"
# run: |
# $SSH "#! /bin/bash -e
# $TUTOR local do settheme indigo
# "
- name: "Provision: Create users"
run: |
$SSH "#! /bin/bash -e
$TUTOR local do createuser --staff --superuser --password=admin admin [email protected]
$TUTOR local do createuser --password=student student [email protected]
"
# Unfortunately ecommerce user creation may not be automated because the admin
# user needs to login from the frontend first. We could use the ecommerce
# createsuperuser management command instead, but it reads the password
# interactively from the user, which is not going to work in this CI.
# - name: Create ecommerce admin user
# run: |
# $SSH "#! /bin/bash -e
# $TUTOR local run ecommerce ./manage.py shell -c "from django.contrib.auth import get_user_model; get_user_model().objects.filter(email='[email protected]').update(is_staff=True, is_superuser=True)"
# "
- name: "Provision: Import demo course"
run: $SSH "$TUTOR local do importdemocourse"
- name: "Prune Docker system"
run: $SSH "docker system prune -a -f --volumes"
# - name: "Provision: Import test course & libraries"
# run: |
# $SSH "#! /bin/bash -e
# cd ~/apps/openedx
# rm -rf openedx-test-course
# git clone https://github.com/openedx/openedx-test-course
# cd openedx-test-course
# $TUTOR local run -v $(pwd):/openedx/data/openedx-test-course cms ./manage.py cms import_content_library /openedx/data/openedx-test-course/dist/test-problem-bank.tar.gz admin
# $TUTOR local run -v $(pwd):/openedx/data/openedx-test-course cms ./manage.py cms import /openedx/data openedx-test-course/test-course/course
# $TUTOR local run cms ./manage.py cms reindex_course --all --setup
# "