You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
wish/deploy.sh

47 lines
946 B
Bash

#!/bin/sh
set -eux
if test "$#" -gt 1; then
echo >&2 "Usage: $0 [branch]"
exit 2
fi
# Check that worktree is clean
if test -n "$(git status --porcelain)"; then
echo >&2 "FATAL: Tree not clean, refusing to deploy"
echo "Hint: This is current \`git status\`:"
git status
exit 1
fi
local branch
if test "$#" -eq 1; then
branch="$1"
else
branch=master
fi
local currentbranch="$(git branch --show-current)"
# If we are not on target branch, switch and run again
if test "$currentbranch" -ne "$branch"
exec /bin/sh -eu "git checkout $branch && exec $0"
fi
echo "Deploying branch $branch"
### Deploying starts here ###
git pull
. venv/bin/activate
pip install -U pip setuptools
pip install -r requirements.txt
./manage.py migrate
./manage.py collectstatic # --noinput?
systemctl --user restart wish.service
# TODO: Self-checks? i.e. ./manage.py --check and ./manage.py test?
echo # Just a blank line
echo '=== Deploy successful ==='