Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. PORT=9000
  4. APP_NAME=""
  5. APP_ROOT=""
  6. GIT_DIR=""
  7. BRANCH=""
  8.  
  9. while read oldrev newrev ref
  10. do
  11. if [[ $ref = refs/heads/"$BRANCH" ]];
  12. then
  13. echo "Stopping $APP_NAME"
  14. pm2 stop "${APP_NAME}"
  15. echo "Ref $ref received. Deploying ${BRANCH} branch to production..."
  16. git --work-tree="$APP_ROOT" --git-dir="$GIT_DIR" checkout -f
  17. echo "Installing dependencies"
  18. cd "$APP_ROOT"
  19. yarn install
  20. echo "Restarting the app"
  21. PORT="$PORT" pm2 start ./bin/www --name "${APP_NAME}"
  22. echo "Build Succeeded!"
  23. else
  24. echo "Ref $ref received. Doing nothing: only the ${BRANCH} branch may be deployed on this server."
  25. fi
  26. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement