Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.68 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. echo "Content-type:text/plain\n"
  4.  
  5. if
  6.   [ -n "$HTTP_X_HOOK_UUID" ] &&
  7.   [ -n "$HTTP_X_REQUEST_UUID" ] &&
  8.   [ "$HTTP_X_EVENT_KEY" = "repo:push" ] &&
  9.   [ "$HTTP_CONTENT_TYPE" = "application/json" ] &&
  10.   [ "$REQUEST_METHOD" = "POST" ]
  11. then
  12.   MASTER_COMMITS=`jq '[.push.changes[].new | select(.name == "master" and .type == "branch")] | length'`
  13.  
  14.   if [ "$MASTER_COMMITS" -gt 0 ]
  15.   then
  16.     cd ./repo
  17.  
  18.     GIT_SSH_COMMAND='ssh -i /var/www/deploy/access-key -o UserKnownHostsFile=/dev/null'
  19.     git fetch --all 2>&1
  20.     git reset --hard origin/master
  21.     ./build.sh
  22.  
  23.     echo "Build complete"
  24.   else
  25.     echo "Build skipped"
  26.   fi
  27. else
  28.   echo "Wrong request"
  29. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement