-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathdeploy.sh
executable file
·51 lines (43 loc) · 1.05 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
49
50
51
#!/usr/bin/env bash
set -euo pipefail
PROJECT_NAME=${PROJECT_NAME:-lyceum}
DEPLOY_USER=${DEPLOY_USER:-deploy}
DEPLOY_HOST=""
while [[ "$#" -gt 0 ]]; do
case "$1" in
--deploy-host)
DEPLOY_HOST="$2"
shift 2
;;
--deploy-user)
DEPLOY_USER="$2"
shift 2
;;
*)
echo "Unknown option: $1"
exit 1
;;
esac
done
if [[ -z "$DEPLOY_HOST" ]]; then
echo "Usage: $0 --deploy-host <hostname> [--deploy-user <user>]?"
exit 1
fi
# TODO: Copy the /ebin folder
echo "[SYNC] Pushing new version to server..."
rsync \
-azP \
--mkpath \
--delete \
--exclude-from .rsyncignore \
. \
$DEPLOY_USER@$DEPLOY_HOST:~/$PROJECT_NAME
# Build the server locally
nix build .#server
# And copy the build to the Host
nix copy \
--no-check-sigs \
--to ssh-ng://$DEPLOY_HOST ".#server"
echo "[DEPLOY] Running entrypoint script..."
PROJECT_NAME=$PROJECT_NAME \
ssh $DEPLOY_USER@$DEPLOY_HOST "cd ~/$PROJECT_NAME && just start"