-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·61 lines (52 loc) · 1.33 KB
/
Copy pathdeploy.sh
File metadata and controls
executable file
·61 lines (52 loc) · 1.33 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
58
59
60
61
#!/bin/bash
set -e
REMOTE=$(git remote get-url origin)
DEPLOY_BRANCH="gh-pages"
CLIENT_DIR="client"
if ! [ -d "$CLIENT_DIR" ]; then
echo "Client directory '$CLIENT_DIR' not found. Make sure you're in the project root."
exit 1
fi
cd $CLIENT_DIR
if command -v npm &> /dev/null; then
PACKAGE_MANAGER="npm"
BUILD_COMMAND="npm run build"
INSTALL_COMMAND="npm install"
elif command -v yarn &> /dev/null; then
PACKAGE_MANAGER="yarn"
BUILD_COMMAND="yarn build"
INSTALL_COMMAND="yarn"
elif command -v pnpm &> /dev/null; then
PACKAGE_MANAGER="pnpm"
BUILD_COMMAND="pnpm build"
INSTALL_COMMAND="pnpm install"
else
echo "No package manager found (npm, yarn, or pnpm). Please install one."
exit 1
fi
if ! [ -d "node_modules" ]; then
$INSTALL_COMMAND
fi
rm -rf build || true
if ! $BUILD_COMMAND; then
echo "Build failed, exiting."
exit 1
fi
if ! [ -d "build" ]; then
echo "Build directory 'build' not found. Check your build configuration."
exit 1
fi
cd build
echo "ubacm.org" > CNAME
cp index.html 404.html
git init . -b gh-pages
git remote add origin $REMOTE
git fetch origin $DEPLOY_BRANCH 2>/dev/null || true
git add .
git commit -m "Deployment to ubacm.org - $(date)"
if git push --force origin gh-pages; then
echo "Deployment successful!"
else
echo "Deployment failed"
exit 1
fi