Skip to content

Instantly share code, notes, and snippets.

@stephenturner
Forked from klmr/deploy.sh
Created June 9, 2016 17:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stephenturner/1271eef3ae8f9aa35e1f21bc3376d755 to your computer and use it in GitHub Desktop.
Save stephenturner/1271eef3ae8f9aa35e1f21bc3376d755 to your computer and use it in GitHub Desktop.
Deploy a generated GitHub page (`_site` subfolder)
#!/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