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.
47 lines
1.0 KiB
Bash
47 lines
1.0 KiB
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
|
|
|
|
if test "$#" -eq 1; then
|
|
branch="$1"
|
|
else
|
|
branch=master
|
|
fi
|
|
|
|
# TODO: When deployment is new enough, use the top command.
|
|
#currentbranch="$(git branch --show-current)"
|
|
currentbranch="$(git branch --format '%(refname:short)')"
|
|
|
|
# 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 ==='
|