This repository has been archived by the owner on Dec 16, 2024. It is now read-only.
Deploy #150
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 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 | |
VENV: ~/venv | |
PIP: ~/venv/bin/pip | |
TUTOR: ~/venv/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: Create virtualenv | |
run: | | |
$SSH "#! /bin/bash -e | |
rm -rf $VENV | |
python3 -m venv $VENV | |
" | |
- 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 --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 --upgrade --editable git+https://github.com/overhangio/tutor.git@$VERSION#egg=tutor | |
$PIP install --upgrade --editable git+https://github.com/overhangio/tutor-mfe.git@$VERSION#egg=tutor-mfe | |
$PIP install --upgrade --editable git+https://github.com/overhangio/tutor-indigo.git@$VERSION#egg=tutor-indigo | |
$PIP install --upgrade --editable git+https://github.com/overhangio/tutor-discovery.git@$VERSION#egg=tutor-discovery | |
$PIP install --upgrade --editable git+https://github.com/overhangio/tutor-credentials.git@$VERSION#egg=tutor-credentials | |
$PIP install --upgrade --editable git+https://github.com/overhangio/tutor-ecommerce.git@$VERSION#egg=tutor-ecommerce | |
$PIP install --upgrade --editable git+https://github.com/overhangio/tutor-forum.git@$VERSION#egg=tutor-forum | |
$PIP install --upgrade --editable git+https://github.com/overhangio/tutor-minio.git@$VERSION#egg=tutor-minio | |
$PIP install --upgrade --editable git+https://github.com/overhangio/tutor-notes.git@$VERSION#egg=tutor-notes | |
$PIP install --upgrade --editable git+https://github.com/overhangio/tutor-xqueue.git@$VERSION#egg=tutor-xqueue | |
$PIP install --upgrade --editable git+https://github.com/overhangio/tutor-android.git@$VERSION#egg=tutor-android | |
$PIP install --upgrade --editable git+https://github.com/overhangio/tutor-jupyter.git@$VERSION#egg=tutor-jupyter | |
$PIP install --upgrade --editable git+https://github.com/overhangio/tutor-webui.git@$VERSION#egg=tutor-webui | |
$PIP install --upgrade --editable git+https://github.com/openedx/[email protected]#egg=tutor-contrib-aspects | |
$PIP install --upgrade --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 | |
run: $SSH "$TUTOR plugins enable indigo mfe aspects codejail credentials discovery ecommerce forum 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: "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 | |
# " |