-
-
Save stephenturner/1271eef3ae8f9aa35e1f21bc3376d755 to your computer and use it in GitHub Desktop.
Deploy a generated GitHub page (`_site` subfolder)
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
#!/usr/bin/env bash | |
# Configuration | |
remote_target=master | |
destination=_site | |
get-working-branch() { | |
git status | head -n 1 | awk '{ print $NF }' | |
} | |
cleanup() { | |
git checkout "$working_branch" | |
} | |
trap cleanup EXIT | |
remote="$(git remote | head -n 1)" | |
working_branch="$(get-working-branch)" | |
git branch --delete --force "$remote_target" | |
git checkout -b "$remote_target" | |
git add --force "$destination" | |
git commit --message "New version $(date)" | |
git filter-branch --subdirectory-filter "$destination/" --force | |
git push "$remote" "$remote_target" --force | |
# vim: ft=sh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment