Skip to content

Instantly share code, notes, and snippets.

@LaisGalvao
Forked from sam-ngu/deploy.sh
Created July 26, 2022 16:10
Show Gist options
  • Save LaisGalvao/31786bcc33bd259e79a85ac4d0c1c70c to your computer and use it in GitHub Desktop.
Save LaisGalvao/31786bcc33bd259e79a85ac4d0c1c70c 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