|
All articles are licensed under CC0 1.0 making them public domain. Auto deploying to a webserver #Last updated February 2021 Git on the server has mechanisms to run scripts when certain actions occur, these are called Git Hooks. The following is a setup using the NOTE: This only applies to self-hosted Git servers, not services like GitHub. post-receive ScriptThis file should be located at
#!/bin/bash
while read oldrev newrev ref
do
if [[ $ref =~ .*/master$ ]];
then
echo "Deploying changes to web server"
git --work-tree=$HOME/Sites/example --git-dir=$HOME/example.git checkout -f
fi
done
|