-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·57 lines (46 loc) · 1.27 KB
/
deploy.sh
File metadata and controls
executable file
·57 lines (46 loc) · 1.27 KB
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
52
53
54
55
56
57
#!/usr/bin/env bash
set -euo pipefail
STAMP=$(date +%Y-%m-%d-%H%M%S)
OUTDIR=~/builds/$STAMP
SITE=/var/www/dougk.world
# Detect distro
if [ -f /etc/os-release ]; then
. /etc/os-release
DISTRO="${ID:-unknown}"
else
DISTRO="unknown"
fi
echo "▶ Detected distro: $DISTRO"
# Ensure builds directory exists
mkdir -p ~/builds
echo "▶ npm ci"
npm ci
echo "▶ npm run build"
npm run build
mv dist "$OUTDIR"
echo "▶ copy into releases"
sudo mkdir -p "$SITE/releases"
sudo rsync -az --delete "$OUTDIR"/ "$SITE/releases/$STAMP/"
# SELinux context fix (Alma/RHEL/Fedora only)
case "$DISTRO" in
almalinux|rhel|centos|fedora|rocky)
echo "▶ fix selinux context"
sudo restorecon -Rv "$SITE/releases/$STAMP"
;;
nixos|arch|manjaro|endeavouros)
echo "▶ skipping selinux (not used on $DISTRO)"
;;
*)
# Fallback: run restorecon if available
if command -v restorecon &>/dev/null; then
echo "▶ fix selinux context"
sudo restorecon -Rv "$SITE/releases/$STAMP"
fi
;;
esac
echo "▶ flip current symlink"
sudo rm -rf "$SITE/current"
sudo ln -s "$SITE/releases/$STAMP" "$SITE/current"
echo "▶ reload nginx"
sudo systemctl reload nginx
echo "✓ Deployed dougk $STAMP on $DISTRO"