DevOps-ify | Creating a CI/CD pipeline using GitHub Actions
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
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 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:
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, 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.
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
-
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).
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:
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 ✌️
Main article at dev.to