# The first GitHub Actions


## 1\. Introduction

[GitHub Actions](https://github.com/features/actions) makes it easy to automate all your software workflows, now with world-class CI/CD. Build, test, and deploy your code right from GitHub. Make code reviews, branch management, and issue triaging work the way you want.

To get more details about GitHub Actions you can see [About GitHub Actions](https://help.github.com/en/articles/about-github-actions)

## 2\. Let's start

Make sure that you register Github Actions beta program and also receive an approval email from Github like "You’re in! Get started with GitHub Actions beta"...

In this tutorial, I use my repository called [React Starter Kit](https://github.com/sisa-cafe/react-starter-kit).

***Don't talk any more, go go go...***

### **Step 1: Go to your repository and click on the "Actions" tab**

### **Step 2: Click the button "Set up a workflow yourself"**

You will see the template below:

```yaml
name: CI

on: [push]

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v1
    - name: Run a one-line script
      run: echo Hello, world!
    - name: Run a multi-line script
      run: |
        echo Add other actions to build,
        echo test, and deploy your project.
```

### **Step 3: Edit the template**

Following the [Workflow syntax for GitHub Actions](https://help.github.com/en/articles/workflow-syntax-for-github-actions)  
and [Set up your GitHub Actions workflow with a specific version of node.js](https://github.com/actions/setup-node)

I edit my first actions like below:

```yaml
name: CI

on: [push]

jobs:
  build:
    name: Build
    runs-on: ubuntu-18.04
    strategy:
      matrix:
        node_version: [10, 12]

    steps:
    - uses: actions/checkout@v1
    - name: Use Node.js ${{ matrix.node_version }}
      uses: actions/setup-node@v1
      with:
        version: ${{ matrix.node_version }}

    - name: yarn install, yarn lint, yarn test, yarn build
      run: |
        yarn install
        yarn lint
        yarn test
        yarn build
```

**Explanation**:  
In the configuration above

* GitHub Actions will trigger on `push` event on any branch
    
* It will use Ubuntu 18.04 `runs-on: ubuntu-18.04`
    
* It will run 2 times on 2 node versions: `node_version: [10, 12]`
    
* It will use `yarn` to run instead of `npm`
    
* It will run `yarn install`, `yarn lint`, `yarn test`, `yarn build`  
    

For further commands please refer to the [Workflow syntax for GitHub Actions](https://help.github.com/en/articles/workflow-syntax-for-github-actions)

### **Step 4: Waiting and getting the result!**

![Github Actions build result](https://res.cloudinary.com/practicaldev/image/fetch/s--bwor7vRZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/iikbg8pkj2cfzm6bh6mm.PNG align="center")

It works fine!!!

## 3\. In conclusion

***So easy to create a simple pipeline with GitHub Actions. It will help you build your project without using any external CI/CD like Circle CI or something like that.***

If you find this article helpful then you can [**buy me a coffee**](https://www.buymeacoffee.com/harshhaareddy)**.**

Follow for more stories like this 😊/ [**GitHub**](https://github.com/NotHarshhaa)**.**
