Skip to content

Commit

Permalink
Fix and improve production deploy script.
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisl8 committed Dec 28, 2024
1 parent 7f57f35 commit 20007f3
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions scripts/deployToProduction.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ cd "${PARENT_DIR}" || exit
printf "\n${YELLOW}Pulling latest changes from the GitHub repo:${NC}\n"
git pull

printf "\n${YELLOW}Installing dependencies...${NC}\n"
printf "\n${YELLOW}Installing fresh dependencies...${NC}\n"
rm -rf node_modules
rm package-lock.json
npm i

# This is built into the web site, so it has to be done before the build, where the build happens.
Expand All @@ -41,6 +43,7 @@ printf "\n${YELLOW}Building client locally...${NC}\n"
npm run build

printf "\n${YELLOW}Preparing remote side for update${NC}\n"
ssh.exe "${USER}@${1}" 'if [ -d ~/Witchazzan/stage ];then rm -rf ~/Witchazzan/stage;fi'
ssh.exe "${USER}@${1}" 'cd ~/Witchazzan || exit && git pull && PATH=~/.nvm/current/bin:$PATH npm i --omit=dev && mkdir stage'

printf "\n${YELLOW}Copying new built web files to server${NC}\n"
Expand All @@ -49,4 +52,4 @@ scp.exe -r dist/* "${USER}@${1}":./Witchazzan/stage
scp.exe server/utilities/version.js "${USER}@${1}":./Witchazzan/server/utilities/version.js

printf "\n${YELLOW}Restarting server:${NC}\n"
ssh.exe "${USER}@${1}" 'cd ~/Witchazzan || exit && rm -rf dist && mv stage dist && PATH=~/.nvm/current/bin:$PATH ~/.nvm/current/bin/pm2 restart Witchazzan'
ssh.exe "${USER}@${1}" 'cd ~/Witchazzan || exit && rm -rf dist && mv stage dist && chmod -R o+rX ~/Witchazzan/dist && PATH=~/.nvm/current/bin:$PATH ~/.nvm/current/bin/pm2 restart Witchazzan'

0 comments on commit 20007f3

Please sign in to comment.