post-receive.sample 750 B

123456789101112131415161718192021222324252627
  1. #!/bin/sh
  2. #
  3. # A git hook script for the "post-receive" event.
  4. #
  5. # The "post-receive" script is run after receive-pack has accepted a pack
  6. # see contrib/hooks/ for a sample, or uncomment the next line and
  7. # rename the file to "post-receive".
  8. # Change your post url and token if needed
  9. # Get the lastest commit log
  10. msg=$(git log -1 --pretty=format:"%s")
  11. # Check whether to active the notice
  12. is_active=$(echo "$msg" | grep "\[deploy\]")
  13. if [ -z "$is_active" ]; then
  14. echo >&2 "[info] Not to auto deploy"
  15. exit 1
  16. fi
  17. # Curl
  18. url=WEB_URL
  19. token=YOUR_TOKEN
  20. echo "================Auto Deploy=================="
  21. curl -H "Content-Type: application/json" -X POST -s -d "{\"token\":\"$token\"}" $url
  22. echo "================Auto Deploy=================="