Skip to content

Instantly share code, notes, and snippets.

@sam-ngu
Created May 23, 2021 05:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sam-ngu/066650d5474a3eba64482114b9cf42c8 to your computer and use it in GitHub Desktop.
Save sam-ngu/066650d5474a3eba64482114b9cf42c8 to your computer and use it in GitHub Desktop.
Bash script to deploy a React app to Github pages
#!/usr/bin/env sh
# abort on errors
set -e
# build
npm run build
# navigate into the build output directory
cd build
# if you are deploying to a custom domain
#echo 'myapp.com' > CNAME
# creating a git repo in the build folder
git init
git add -A
git commit -m 'deploy'
# if you are deploying to https://<USERNAME>.github.io
# git push -f git@github.com:<USERNAME>/<USERNAME>.github.io.git master
# if you are deploying to https://<USERNAME>.github.io/<REPO>
git push -f git@github.com:<USERNAME>/<REPO>.git master:gh-pages
cd -
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment