Add a deploy script
This script should be run to deploy Wish in production. It _should_ do everything needed, but currently it is created without being tested, so no warranties :-) (There will be no warranties anyway, ever :-))newer-dal
parent
3649f8be83
commit
ccbf5c86fc
@ -0,0 +1,46 @@
|
|||||||
|
#!/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 ==='
|
Loading…
Reference in New Issue