The Beginner's Guide To Netlify Continuous Deployment From Github For React Apps - by JJ Ashcraft - HackerNoon - Com - Medium
The Beginner's Guide To Netlify Continuous Deployment From Github For React Apps - by JJ Ashcraft - HackerNoon - Com - Medium
Follow
298 2
While this guide was written for students in Lambda School, it is applicable
to anyone starting out who is confused about how to get continuous
deployment up and running on Netlify. A special shout out to Vim Shah and
Vu Cao who helped with some of the specifics for getting this guide together
quick!
You can follow along by creating a new repo yourself, or grabbing the repo
made during this project and digging into it here.
In the terminal window, change to the directory you want your new repo to
be in. Clone the repo with the command:
create-react-app myapp
This will create a new subdirectory with react app sample code.
Now, let’s make our commit! the -m tells git you are supplying a message to
describe your changes. Please try to give your commit messages some
meaning.
git commit -m'Initial Commit, creates new react app with create-react-
app'
It’ll show you a list of files to be committed. It’s time to push our changes.
Run the command git push
Now, because you are on the master branch, and you own the repo, no pull
request is necessary…the files are automatically added to the repo. This
works for our initial commit, but what if you are working at a company, or
on a project with other people?! We can’t all push to the master branch all
the time. The code will get messy, overwritten and cause all kinds of nasty
conflicts (including conflict between you and your coworkers.)
As you can see, my terminal shows what branch I’m currently on in cyan
after the directory. If yours doesn’t show it, you can run git branch to see
your current branches.
You can see the current branches we have. master and netlify-deploy
When we created our branch, git automatically switches to the new one.
Now any changes you make will only be made on this branch, and leaves
the master unaffected until we combine the two branches.
-so that when someone forks your repository, they can instantly
create a Netlify site using it without having to configure anything
in the UI but still get an identical site configuration.
-so that you can track changes in configuration via version control
and configure some things that aren’t configurable in our UI.
Sound too complicated? Let’s focus in. This file is responsible for assisting
with the build process on Netlify. This file can contain many different
Netlify settings, but the important one for us is modifying how your app is
built when it is deployed. We need to specify to Netlify (see what I did
there?) where your react app lives, where its published build directory will
live, and what command Netlify will run to actually build it.
Open VSCode or your favorite editor, and navigate to your new base project
directory (not in your react app directory). Create a new file called
netlify.toml
[build]
base = "myapp/"
publish = "myapp/build/"
command = "yarn build"
All good now. We are now setup to track this specific branch in the repo.
You should see something similar to this:
If you switch back to Github on your browser and refresh the page, you
should see a yellow box with your new branch and a button called compare
& pull request. This is where we go to see our new branch changes, and
approve them to be merged into master. Click the compare & pull request
button.
# Description
Fixes # (issue)
## Type of change
Please describe the tests that you ran to verify your changes.
Provide instructions so we can reproduce. Please also list any
relevant details for your test configuration
- [ ] Test A
- [ ] Test B
# Checklist:
At this point, your Pull Request automatically added your last commit
message to the subject box. You can leave that, or change it if you like. At
Lambda School, we make our subjects the same as our Trello card subjects
and branch name, for easy tracking. Paste in the template above, make your
changes to each section and click Create Pull Request. Below, you’ll see
that our markdown brackets were changed to checkboxes, and we can
check off everything that was completed.
Now, we can merge our Pull Request for the netlify-deploy branch into our
master branch. If you were on a team, you would assign another member to
review your code, and the project manager would merge in your request
after it’s been approved. Today, you’ll be doing the reviewing and merging.
Going forward, take the time to read through your code for errors and
omissions before merging your pull request. Click Merge Pull Request.
You’ll be switched to the next screen, where we will choose Github as our
Git provider. You’ll be presented with a pop-up window (check your
blocker!) and you’ll need to provide Netlify with access to your Github
account.
If you choose a repo that you do not own, but are a contributor on,
Netlify will give you an option to request permission to deploy from
that repo. You’ll have to wait for permission to be granted before you
can go any further.
For tutorial purposes, select the repo we created today and you’ll be shown
the following screen. The publish directory and build command you
supplied in the netlify.toml file should be prefilled.
If you followed all the steps correctly, you’ll see Site deploy in progress
switch to green, and display your new URL. Feel free to change the name of
the site they give you, it will not affect any of the deployment. Click on
Change site Name.
1. https://www.netlify.com/blog/2016/07/20/introducing-deploy-
previews-in-netlify/
2. https://www.netlify.com/blog/2017/11/16/get-full-control-over-your-
deployed-branches/
3. https://www.netlify.com/docs/continuous-deployment/#branches-
deploys
[[redirects]]
from = "/*"
to = "/index.html"
status = 200
That’s all for today…sign up below for some killer tips on nailing your job
search. What to do, what NOT to do…the best info is in there.
how hackers start their afternoons. the real shit is on hackernoon.com. Take a look.
By signing up, you will create a Medium account if you don’t already have one. Review our Privacy Policy for more information
about our privacy practices.
298 2
WRITTEN BY
JJ Ashcraft Follow
HackerNoon.com Follow
Facebook Authentication Custom domain setup No-Frills Guide to Adding Owl Carousel in
in ionic 😍 with Firebase hosting and Creating a REST API with Angular 7/8/9
Usama Liaquat
namecheap Node (Part 1) Shreya
Joe Peter Ajtai in Solid Digital
Understand Web Change my dev log to Interview Questions Make Your Angular
Development medium (BlogPost_405) Form’s Error Messages
Programming Languages member Henrique Flores
Magically Appear
in 2018 Netanel Basal in Netanel Basal
Jordan Mauricio in Level Up
Coding