<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Cates NSENGIYUMVA</title>
    <description>The latest articles on Forem by Cates NSENGIYUMVA (@ktscates).</description>
    <link>https://forem.com/ktscates</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F765639%2Fe83db9fe-d4ce-4a3d-992a-80bd1094f211.jpeg</url>
      <title>Forem: Cates NSENGIYUMVA</title>
      <link>https://forem.com/ktscates</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/ktscates"/>
    <language>en</language>
    <item>
      <title>Deploy a React app to netlify using GitHub Actions</title>
      <dc:creator>Cates NSENGIYUMVA</dc:creator>
      <pubDate>Fri, 03 Dec 2021 13:53:35 +0000</pubDate>
      <link>https://forem.com/ktscates/deploy-a-react-app-to-netlify-using-github-actions-3akd</link>
      <guid>https://forem.com/ktscates/deploy-a-react-app-to-netlify-using-github-actions-3akd</guid>
      <description>&lt;p&gt;This guide takes you through how to deploy a react app using the GitHub actions.&lt;/p&gt;

&lt;h3&gt;
  
  
  My Workflow
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Create a react app project with the following command:&lt;br&gt;
&lt;code&gt;npx create-react-app my-app&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Run &lt;code&gt;npm run build&lt;/code&gt; to generate a build folder which will be use in netlify.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Create the app repository in GitHub.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Create a &lt;code&gt;netlify.toml&lt;/code&gt; file locally in the project directory and paste the following:&lt;br&gt;
&lt;code&gt;[build]&lt;br&gt;
command = "npm run build"&lt;br&gt;
publish = "build"&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Push the local changes to your repository.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In your project repository, go to actions and setup the Node.js workflow, which will generate a yaml file. You have to copy/paste the workflow which you can be found in the screenshot provided below in this article in the yaml file.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Login to your netlify account and create a new site, you will have to drag/drop the build folder generated before in step 2.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Generate a personal access token in the user settings.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fntji0v8sxu4osbf4kmpo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fntji0v8sxu4osbf4kmpo.png" alt="Personal token"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Copy the personal token &amp;amp; API ID, found in site settings in netlify, in secrets in the project settings.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ficg3geyhyes9bwwcakm0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ficg3geyhyes9bwwcakm0.png" alt="Netlify API ID"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Replace the tokens in the yaml file with your tokens from the secrets.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdxqx5zjgzqy1hh6co5cn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdxqx5zjgzqy1hh6co5cn.png" alt="Github secrets"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- name: Netlify Deploy

      env:
        NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
        NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
      run: netlify deploy --prod

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Submission Category:
&lt;/h3&gt;

&lt;p&gt;This is my submission to &lt;a href="https://dev.to/devteam/join-us-for-the-2021-github-actions-hackathon-on-dev-4hn4"&gt; GitHub Actions Hackathon&lt;/a&gt; under &lt;strong&gt;DIY Deployments&lt;/strong&gt;. &lt;/p&gt;

&lt;h3&gt;
  
  
  Yaml File or Link to Code
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://github.com/ktscates/test-pipeline" rel="noopener noreferrer"&gt;Github link repo&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# This workflow will do a clean install of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Netlify workflow

on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

jobs:
  build:

    runs-on: ubuntu-latest

    strategy:
      matrix:
        node-version: [12.x]
        # See supported Node.js release schedule at https://nodejs.org/en/about/releases/

    steps:
    - uses: actions/checkout@v2

    - name: Use Node.js ${{ matrix.node-version }}
      uses: actions/setup-node@v2
      with:
        node-version: ${{ matrix.node-version }}
        cache: 'npm'

    - run: npm i

    - run: npm run build --if-present

    - name: Run the tests and generate coverage report
      run: npm test -- --coverage

    - name: Codecov
      uses: codecov/codecov-action@v2.1.0

    - name: Netlify Deploy
      # uses: jsmrcaga/action-netlify-deploy@v1.7.1

      env:
        NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
        NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
      run: netlify deploy --prod

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Additional Resources / Info
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://github.com/marketplace/actions/netlify-actions" rel="noopener noreferrer"&gt;https://github.com/marketplace/actions/netlify-actions&lt;/a&gt;&lt;/p&gt;

</description>
      <category>actionshackathon21</category>
      <category>javascript</category>
      <category>githubactions</category>
      <category>netlify</category>
    </item>
  </channel>
</rss>
