-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy.sh
executable file
·66 lines (58 loc) · 1.95 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
62
63
64
65
66
# A bash script to push to GitHub and deploy to GitHub Pages
# git add .
# git commit -m "$commitMessage"
# git push origin main
# npm run deploy
echo -e "${GREEN}Start Deploying...${NC}"
# REPONAME
REPO_NAME="hkdjyu.github.io"
# Color Setting
RED='\033[1;31m'
GREEN='\033[1;32m'
YELLOW='\033[1;33m'
BLUE='\033[1;34m'
NC='\033[0m' # No Color
# Ask user to type commit message in yellow color
echo -e "${YELLOW}Type your commit message?${NC}"
read commitMessage
# Check commitMessage is empty or not. If empty, keep asking.
while [ -z "$commitMessage" ]
do
echo -e "${YELLOW}Commit message cannot be empty. Please type again. (press ctrl + c to exit))${NC}"
read commitMessage
done
echo -e "${GREEN}Your commit message is: ${BLUE}$commitMessage${NC}"
dir=$PWD
if [[ $dir == *"$REPO_NAME" ]];
then
echo -e "${YELLOW}Your current directory: ${BLUE}$dir${NC}"
else
echo -e "${RED}Your current directory does not have \"$REPO_NAME\"${NC}"
# Ask user to type Yes or No. If Yes, continue the bash program. If No, exit the bash program.
while true; do
echo -e "${YELLOW}Do you want to continue? (Y/N)${NC}"
read yn
case $yn in
[Yy]* ) echo -e "${GREEN}Continue${NC}"; break;;
[Nn]* ) echo -e "${RED}Exit${NC}"; exit;;
* ) echo -e "${YELLOW}Please answer yes or no.${NC}";;
esac
done
fi
echo -e "${GREEN}Start Pushing to GitHub... Please wait the pushed message.${NC}"
git add .
git commit -m "$commitMessage"
git push origin main
echo -e "${GREEN}Pushed to GitHub...${NC}"
# Ask if user want to deploy to GitHub Pages
while true; do
echo -e "${YELLOW}Do you want to deploy to GitHub Pages? (Y/N)${NC}"
read yn
case $yn in
[Yy]* ) echo -e "${BLUE}Deploying to GitHub Pages... Please wait the deployed message.${NC}"; break;;
[Nn]* ) echo -e "${RED}Exit${NC}"; exit;;
* ) echo -e "${YELLOW}Please answer yes or no.${NC}";;
esac
done
npm run deploy
echo -e "${GREEN}Deployed to GitHub Pages...${NC}"