DevOps-ify | Creating a CI/CD pipeline using GitHub Actions
Tags: github, workflow, javascript, automation
Published: 2021-03-07 08:50:08

As a developer, you'd like to automate the process as much as possible of repetitive tasks. If you have no idea what terms like Continous Integration and Continous Delivery means then after reading this full article you can easily automate your own project and create some hell out of it.

##Overview of what you'll learn📘💡

* what is GitHub Action
* how GitHub actions works
* the workflow, CI/CD Pipeline
* hands-on demo 
* you can explore and experiment with different use cases of GitHub actions

![Here we go](https://media.giphy.com/media/efPA2YD9BFWS30GJ5v/giphy.gif)

###What is GitHub Actions?
Actions, the events that take place in our GitHub repository like pushes, pull requests, releases, etc. are used as triggers to kick-off the workflows. These workflows are coded in YAML format.

If there's an error in the code the server build will fail automatically notify the developers about the issues integrating into their changes.

####What is CI/CD?

![ci/cd](https://www.redhat.com/cms/managed-files/ci-cd-flow-desktop_1.png)

*CI/CD is a way of developing software in which you’re able to release updates at any time in a sustainable way. When changing code is routine, development cycles are more frequent, meaningful and faster.*

###Workflow Config file

Creating the workflow file:
![ci-cd](https://user-images.githubusercontent.com/33036554/110231923-989d1d00-7f40-11eb-935a-6fc7737cefd4.png)

The config file is the workflow of the events (step by step) and you can add steps according to your production environment.

You can create this workflow config file in your root project folder like `.github/workflows/actions.yml` 

The `actions.yml` file contains the workflow and [published by the community](https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions), which is reusable for you.

Here's the **workflow config file for automating the process of deploying your web app to your firebase hosting** which I use mostly. Here `FIREBASE-TOKEN` is the secret key that you add to your repo manually.


```javascript
name: Firebase CD

on:
  push:
    branches: [master]

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@master
    - uses: w9jds/firebase-action@master
      with:
        args: deploy --only hosting
      env: 
        FIREBASE_TOKEN: ${{secrets.FIREBASE_TOKEN}}
```


These above-given steps are the combination of:

* Shell commands 
* actions - an external action [Actions Marketplace](https://github.com/marketplace)
![Screenshot 2021-03-07 at 12 42 54 PM (2)](https://user-images.githubusercontent.com/33036554/110234012-1156a600-7f4e-11eb-896b-fb873f03dd16.png)

* Jobs - what actually executes, and you can name it anything

These all are the key parts of the workflow. For better understanding, you can have a look at this image given below (Pic Courtesy - [Semaphore](https://semaphoreci.com/)).

![CI/CD pipeline](https://wpblog.semaphoreci.com/wp-content/uploads/2019/09/ci-cd-693x1024.png)


Benefits 👍

* If anyhow the build fails the bad product will not be delivered to your customers and it indicates there's an issue that needs to be addressed.
* GitHub already has a long list of workflows so you don't need to write each one from scratch.
* Fast CI/CD for any OS, any language, and any cloud.
* Improves the code quality by detecting the small problems early before they become a major disaster.

That's the advantage of using GitHub Actions 🌟

References:
 
* [GitHub Blog](https://github.blog/2019-08-08-github-actions-now-supports-ci-cd/)
* [Fireship](https://www.youtube.com/watch?v=scEDHsr3APg)

If you want me to write a detailed article on creating pipelines step by step using GitHub actions, do comment. Stay tuned for upcoming articles ✌️