Bash script that automatically builds and deploys a static Gatsby site to GitHub Pages.
- Move all of your code to a new directory called
code
inside the root directory (root should be empty) - Copy the
deploy.sh
script to the code directory - Run the script using
./deploy.sh
- Installs all the required dependencies using
npm install
and then does a build usinggatsby build
- Copies all of the generated static files to the root dir from the code dir
- Creates a new temp branch with the build number, ignores the code dir, and pushes all the other files
- Merges the temp branch with main
- Deletes all the files in the root dir in your local
- Deletes the temp branch
These are the default values present in the script, feel free to change any of these to suit your needs.
- Your release branch is called
main
(this is the branch that GitHub Pages is deployed from) - Your latest changes live in a branch called
develop