Last active
August 22, 2021 14:16
-
-
Save ivangabriele/1ca08023a99e65a6ffc5dc45a0ec7741 to your computer and use it in GitHub Desktop.
Github Post Receive Hook
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/bash | |
# Exit when any command fails: | |
set -e | |
TARGET="/home/.../deployments/matomo" | |
GIT_DIR="/home/.../repositories/matomo.git" | |
BRANCH="main" | |
while read oldrev newrev ref | |
do | |
# Only checking out the specified branch: | |
if [[ $ref = "refs/heads/${BRANCH}" ]] | |
then | |
echo "Git reference $ref received. Deploying ${BRANCH} branch to production..." | |
git --work-tree="$TARGET" --git-dir="$GIT_DIR" checkout -f "$BRANCH" | |
cd $TARGET | |
sudo make start | |
else | |
echo "Git reference $ref received. Doing nothing: only the ${BRANCH} branch may be deployed on this server." | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment