Github Actions: How to deploy a React Application to Netlify

A simple Github Action to use in your repository Github to deploy an application to Netlify

In this article I want to show you how to use a Github Actions. In the specific, in this article we want to deploy a React Application to Netlify.

First step — Create a Github Actions

Going into a your Github Repository of your application, click the tabs Actions, then click on “Skip this and set up a workflow yoursel”

How to create your first action

Now you can copy/paste this yaml:

Replace the line 29 with your commands but, by default in a CRA the commands is npm run build to create a build folder.

Bonus Point
If you want to trigger manually this Github Action, replace the line 3 with this: on: workflow_dispatch

Second step — Create the secrets

Before to run our new Github Action, we need to create a new secrets into the Github account. So, enter again in your repository and click in the tabs “Settings”.

In the left menu click “Secrets” and now add two new secrets:

  • NETLIFY_AUTH_TOKEN — with a new token generated from Netlify
  • NETLIFY_SITE_ID — the app id of your application on Netlify

Last step — Try your Github Actions

So, now you can try your Github Action.

Go to:
- Repository
- Tab Actions
- Select the workflow
- Click run workflow (if you have setted on workflow_dispatch)

How to launch manually a workflow
How to launch manually the workflow

Please visit (add a star 🔥) the repository where you find the yml: https://github.com/crtdaniele/react-personal-site

Follow me on LinkedIn: https://www.linkedin.com/in/daniele-carta-milano

--

--

Hi, I’m Daniele Carta, Frontend Engineer @ illimity Bank. I love to coding and share online my knowledge with free e-book and free articles.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Daniele Carta

Hi, I’m Daniele Carta, Frontend Engineer @ illimity Bank. I love to coding and share online my knowledge with free e-book and free articles.