-
Notifications
You must be signed in to change notification settings - Fork 1
/
deploy.sh
executable file
·48 lines (38 loc) · 1.29 KB
/
deploy.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env bash
# Get date and timestamp to ensure unique filenames.
# https://man7.org/linux/man-pages/man1/date.1.html
# https://www.geeksforgeeks.org/date-command-linux-examples/
# Structured like this: <date>__<timestamp>
# Outputs: <day>_<month>_<year>__<hours>_<minutes>_<seconds>
# Example: 19_11_2023__23_02_57
now="$(date +"%m_%d_%Y__%H_%M_%S")"
filename="backend/logs/deploy__$now.log"
echo "Running deploy script..."
echo "See logs in $filename"
# https://serverfault.com/questions/103501/how-can-i-fully-log-all-bash-scripts-actions
# Redirect all commands, results and errors to a log file.
exec 1> "$filename" 2>&1
# https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html
# -e: Stop script on first failed command.
# -x: Trace executed commands.
set -ex
# Fetch latest changes.
# -f: force pull, overwrite local changes.
git pull -f origin master
##################################
# Frontend #
##################################
cd frontend || exit
yarnpkg run ci:debian
yarnpkg run build
cd ..
##################################
# Backend #
##################################
cd backend || exit
source aliases.sh
poetry-sync-prod
poetry-migrate-apply
poetry-run-collectstatic
touch reload # Trigger restart of uwsgi server.
cd ..