Created
March 15, 2018 01:54
-
-
Save ninapavlich/8177b86fdc98eb63caa5885ece8cbee9 to your computer and use it in GitHub Desktop.
Manually check if repo has been updated
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
GIT_DIR="/srv/project-name/src/" | |
RESTART_SCRIPT="sh /etc/project-name/deploy.sh" | |
SLACK_WEBHOOK="https://hooks.slack.com/services/XXXXXX/XXXXXX/XXXXXXXXXXXX" | |
SLACK_CHANNEL="#development" | |
echo "Fetching..." | |
git --git-dir=$GIT_DIR.git --work-tree=$GIT_DIR fetch | |
LOCAL=$(git --git-dir=$GIT_DIR.git --work-tree=$GIT_DIR rev-parse @{u}) | |
REMOTE=$(git --git-dir=$GIT_DIR.git --work-tree=$GIT_DIR rev-parse HEAD) | |
echo "Local is at $LOCAL ... Remote is at $REMOTE" | |
if [ $LOCAL = $REMOTE ]; then | |
echo "Up-to-date" | |
else | |
echo "Need to pull" | |
OUTPUT_UPDATE=$(eval $RESTART_SCRIPT) | |
/usr/bin/curl \ | |
-X PUT \ | |
-s \ | |
--data-urlencode "payload={ \ | |
\"channel\": \"$SLACK_CHANNEL\", \ | |
\"pretext\": \"New deployment at $GIT_DIR\", \ | |
\"text\": \"Deployment at $GIT_DIR dated to $REMOTE: $OUTPUT_UPDATE\" \ | |
}" \ | |
$SLACK_WEBHOOK | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment