-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy.sh
61 lines (51 loc) · 1.42 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
52
53
54
55
56
57
58
59
60
61
#!/bin/bash
setup() {
# Load the environment variables
source ./.env
# Check if TARGET_DIR is set
if [ -z "$TARGET_DIR" ]; then
echo "TARGET_DIR is not set in .env file"
exit 1
fi
# Check if the target directory exists
if [ ! -d "$TARGET_DIR" ]; then
echo "Creating target directory: $TARGET_DIR"
mkdir -p "$TARGET_DIR"
else
# Clean the target directory by removing all files
echo "Cleaning target directory: $TARGET_DIR"
rm -r "$TARGET_DIR"/*
fi
}
build_playground() {
# Build the playground
yarn build
# # Move files to the target directory
cp -r build/* "$TARGET_DIR"
}
push_to_live() {
# Change the to the target directory
cd "$TARGET_DIR"
# Check if there are any changes to deploy
# if git status --porcelain | grep -q '^[AM]'; then
if [ -n "$(git status --porcelain)" ]; then
echo
echo "Deploying the changes to the live site"
echo "--------------------------------------"
# Push the changes to the remote git repository
git checkout live
git add .
git commit -m "Deployed on $(date +'%Y-%m-%d %H:%M:%S')"
git push origin live
echo
echo "--------------------------------------"
echo "Deployment completed successfully"
echo "Wait for a few seconds for the changes to reflect on"
echo "https://play.internetobject.org/"
else
echo "No changes to deploy!"
fi
}
setup
build_playground
push_to_live