mirror of
https://gitlab.science.ru.nl/technicie/MarietjeDjango.git
synced 2025-12-08 04:32:21 +01:00
53 lines
2.0 KiB
YAML
53 lines
2.0 KiB
YAML
stages:
|
|
- test
|
|
- deploy
|
|
|
|
image: debian:11.3
|
|
|
|
black:
|
|
stage: test
|
|
before_script:
|
|
- apt update -qq
|
|
- apt install -qq -y python3 python3-venv python3-pip python3-dev curl default-libmysqlclient-dev build-essential pkg-config
|
|
- python3 -m pip install --upgrade pip
|
|
- curl -sSL https://install.python-poetry.org | python3 -
|
|
- export PATH="/root/.local/bin:$PATH"
|
|
- poetry install --with dev
|
|
script:
|
|
- poetry run black --quiet --check marietje
|
|
|
|
# TODO: Fix the deploy stage, as it has not been adapted to the new server Marietje runs on. The . disables the stage.
|
|
.deploy:
|
|
stage: deploy
|
|
only: ['marietje-zuid']
|
|
before_script:
|
|
- apt-get -qq update
|
|
- apt-get -qq install -y git openssh-client
|
|
script: |
|
|
umask 077
|
|
mkdir -p "$HOME/.ssh"
|
|
cat <<EOF >"$HOME/.ssh/id_rsa"
|
|
$SSH_PRIVATE_KEY
|
|
EOF
|
|
cat <<EOF >>"$HOME/.ssh/known_hosts"
|
|
marietje-zuid.science.ru.nl ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBLticd8NEr6r5QJ2VKFX/rVcfkhM3IcAr+hCgc/kgBSIPEzyRIXd74glIx17FJxvhi2KLC5D+EVtu9CSZhYSe10=
|
|
EOF
|
|
|
|
# Deploy the new version
|
|
cat <<EOF | ssh root@marietje-zuid.science.ru.nl
|
|
readonly PYTHON="/srv/MarietjeDjango/django_env/bin/python"
|
|
readonly MANAGE="/srv/MarietjeDjango/marietje/manage.py"
|
|
|
|
systemctl stop MarietjeDjango.service
|
|
git --git-dir=/srv/MarietjeDjango/.git --work-tree=/srv/MarietjeDjango/ pull origin marietje-zuid
|
|
"\$PYTHON" "\$MANAGE" migrate --noinput
|
|
"\$PYTHON" "\$MANAGE" collectstatic --noinput
|
|
systemctl start MarietjeDjango.service
|
|
|
|
# Regenerate caches
|
|
(
|
|
sudo -u www-data /srv/MarietjeDjango/django_env/bin/python /srv/MarietjeDjango/marietje/manage.py recache_stats
|
|
sudo -u www-data /srv/MarietjeDjango/django_env/bin/python /srv/MarietjeDjango/marietje/manage.py recache_user_stats
|
|
) &
|
|
EOF
|