mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-30 14:57:59 +01:00
48 lines
1.3 KiB
Bash
Executable file
48 lines
1.3 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
# Set up environment
|
|
source ~/bin/philomena-env
|
|
|
|
read oldrev newrev ref
|
|
echo "Updating $oldrev -> $newrev ($ref)"
|
|
|
|
# Clear variable set to '.' so git commands don't complain
|
|
unset GIT_DIR
|
|
|
|
cd ~/philomena
|
|
|
|
die() {
|
|
echo "$*" 1>&2
|
|
exit 1
|
|
}
|
|
|
|
if git diff --name-only $oldrev $newrev | grep -Ee "^mix.(exs|lock)"; then
|
|
echo "Fetching deps"
|
|
mix deps.get || die "mix failed to update"
|
|
fi
|
|
|
|
# Run migrations
|
|
if git diff --name-only $oldrev $newrev | grep "^priv/repo/migrations"; then
|
|
echo "Running database migrations"
|
|
mix ecto.migrate || die "ecto.migrate failed"
|
|
fi
|
|
|
|
# Compile assets
|
|
if git diff --name-only $oldrev $newrev | grep "^assets/"; then
|
|
echo "Compiling assets"
|
|
npm install --prefix ./assets || die "assets install failed"
|
|
npm run deploy --prefix ./assets
|
|
mix phx.digest || die "assets compile failed"
|
|
fi
|
|
|
|
# TODO: fix this when I can figure out how to avoid recompiling
|
|
# the entire project when the version changes
|
|
#
|
|
# # Generate release name to always be the current timestamp so that
|
|
# # it will be considered an upgrade
|
|
# export PHILOMENA_VERSION="0.1.$(date +%s)"
|
|
|
|
echo "Building release"
|
|
mix distillery.release --quiet || die "failed to generate release"
|
|
|
|
_build/prod/rel/philomena/bin/philomena reboot || die "failed to upgrade app; log in to the server and restart the app manually"
|