Deploy #127
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy | |
on: | |
schedule: | |
# Run at 7am every day | |
# - cron: '0 7 * * *' | |
# Run at 7am every Monday | |
- cron: "0 7 * * 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: redwood | |
LMS_HOST: redwood.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: | |
# 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-cairn.git@$VERSION#egg=tutor-cairn | |
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-credentials.git@$VERSION#egg=tutor-credentials | |
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-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-indigo.git@$VERSION#egg=tutor-indigo | |
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-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-webui.git@$VERSION#egg=tutor-webui | |
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/openedx/tutor-contrib-aspects.git@master#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: android cairn | |
run: $SSH "$TUTOR plugins enable aspects credentials discovery ecommerce forum indigo jupyter mfe minio notes webui xqueue codejail" | |
- 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 Redwood Demo' | |
" | |
- name: Install extra xblocks/packages | |
run: | | |
$SSH "#! /bin/bash -e | |
$TUTOR config save --append 'OPENEDX_EXTRA_PIP_REQUIREMENTS=edx-event-routing-backends>=7.2.0,<8.0.0' | |
" | |
- 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: 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 | |
# " |