Skip to content

Instantly share code, notes, and snippets.

@htp
Created July 2, 2020 07:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save htp/25924bb1e586c84ae91add4df53cbccd to your computer and use it in GitHub Desktop.
Save htp/25924bb1e586c84ae91add4df53cbccd to your computer and use it in GitHub Desktop.
A post-receive hook for "deploying" static sites using Git.
#!/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