Skip to content

Instantly share code, notes, and snippets.

@SangsooNam
Created January 6, 2019 23:11
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save SangsooNam/06de16f154d0e9a08b436a7252e80f34 to your computer and use it in GitHub Desktop.
Save SangsooNam/06de16f154d0e9a08b436a7252e80f34 to your computer and use it in GitHub Desktop.
Script to deploy a target directory to `gh-pages` branch.
#!/bin/bash
directory=_site
branch=gh-pages
build_command() {
jekyll build
}
echo -e "\033[0;32mDeleting old content...\033[0m"
rm -rf $directory
echo -e "\033[0;32mChecking out $branch....\033[0m"
git worktree add $directory $branch
echo -e "\033[0;32mGenerating site...\033[0m"
build_command
echo -e "\033[0;32mDeploying $branch branch...\033[0m"
cd $directory &&
git add --all &&
git commit -m "Deploy updates" &&
git push origin $branch
echo -e "\033[0;32mCleaning up...\033[0m"
git worktree remove $directory
@happycollision
Copy link

Clever use of worktrees. Thanks for sharing this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment