Created
July 2, 2020 07:17
-
-
Save htp/25924bb1e586c84ae91add4df53cbccd to your computer and use it in GitHub Desktop.
A post-receive hook for "deploying" static sites using Git.
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 | |
main() { | |
local temporary="$(mktemp -d)" | |
local repository="/path/to/bare/repository.git" | |
local deployment="/path/to/site/root" | |
echo -n "Copying files... " | |
git --work-tree="${temporary}" --git-dir="${repository}" checkout --force | |
echo "done." | |
echo -n "Deploying changes... " | |
chmod 755 "${temporary}" | |
rm -rf "${deployment}" | |
mv "${temporary}" "${deployment}" | |
echo "done." | |
} | |
main "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment