Created
September 28, 2020 09:18
-
-
Save romanitalian/d2201f7e8327eb42e0261794f02bd276 to your computer and use it in GitHub Desktop.
Deploy Project to remote host by Git Hooks
This file contains hidden or 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 | |
# USAGE "local" (change manualy value in <USER>, <SERVER_HOST>, <SERVER_PORT> and <REPO_DIR>): | |
# | |
# cd ~/wks/src/github.com/<USER>/project | |
# git remote add prod ssh://root@<SERVER_HOST>:<SERVER_PORT><REPO_DIR> | |
# CONFIG | |
WWW_DIR="/var/www/site.com" | |
REPO_DIR="/var/repo/site.com" | |
SERVER_HOST="[email protected]" | |
SERVER_PORT=49336 | |
# RUN | |
ssh -p $SERVER_PORT $SERVER_HOST <<EOF | |
mkdir -p $WWW_DIR && chown -R www-data:www-data $WWW_DIR | |
mkdir -p $REPO_DIR && cd $REPO_DIR | |
git init --bare | |
printf "#!/bin/sh\ngit --work-tree=$WWW_DIR --git-dir=$REPO_DIR checkout -f" >> $REPO_DIR/hooks/post-receive | |
chmod +x $REPO_DIR/hooks/post-receive | |
EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment