Skip to content

Instantly share code, notes, and snippets.

@ksundong
Created June 16, 2020 10:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ksundong/cf5c0da5b0d1a3be97e4efef5cf5671e to your computer and use it in GitHub Desktop.
Save ksundong/cf5c0da5b0d1a3be97e4efef5cf5671e to your computer and use it in GitHub Desktop.
crontab을 이용한 git에서 새로운 버전이 커밋되었을 때, 배포를 하도록 하는 스크립트
#!/bin/bash
echo "===== Check update =====>"
echo $(date)
# check update
cd /Users/idion/Downloads/sidedish-03/BE
git fetch
now=`git rev-parse HEAD`
origin=`git rev-parse origin/master`
echo "[*] now : $now"
echo "[*] origin : $origin"
if [ $now == $origin ]; then
echo "Already up to date"
else
# merge and build
echo "***** BUILD START *****"
git pull
./gradlew build -x test
# move to WEBROOT
scp -i /Users/idion/awskey/ubuntu1804mysql57testdbserver.pem ./build/libs/ROOT.war ubuntu@15.165.21.99:/home/ubuntu/apache-tomcat-9.0.34/webapps/ROOT.war
echo "ROOT.war Successfully Uploaded"
# move to FE directory
cd ../FE/sidedish
# npm install
echo "npm install..."
npm install > /dev/null 2>&1
# npm build
echo "npm build start"
npm run build > /dev/null 2>&1
echo "npm build done"
echo "Upload FE"
scp -i /Users/idion/awskey/ubuntu1804mysql57testdbserver.pem -r ./build/* ubuntu@15.165.21.99:/var/www/html/
echo "Jobs Done"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment