Open In App

How To Create A Basic CI Workflow Using GitHub Actions?

GitHub Actions is a continuous integration and continuous delivery (CI/CD) feature provided by GitHub that allows you to automate your build, test, and deployment pipeline whenever any changes happen in your repo.

Continuous integration (CI) is a software development practice in which you merge/commit your changes to the main branch many times a day. For every change, you have to deploy the whole project again and again to reflect changes in the production environment. This can lead to a decrease in productivity and repetition of tasks.



To eliminate this we have something called CI/CD workflow which allows us to build & deploy our code automatically if any changes happen in a production environment.

In this article, we will create a basic CI workflow where we will make changes to Static HTML and deploy it automatically if we push modified code on GitHub pages. GitHub actions already provide some pre-build workflow for HTML, Node.js, Python, etc.



What Are Github Actions?

GitHub Actions is a platform built into GitHub that automates all the SDLC steps like development, testing, and deployment.

What Is Continuous Integration?

Continuous Integration is a development methodology where the developers commit changes to source code in a shared repository. This typically takes place several times a day.

The benefit is that it enables teams to find and resolve issues early in the development process. There are many tools teams can use to implement Continuous Integration. Depending on what they choose, there are also other functions developers can take advantage of such as using test servers and providing teams with test results.

Creating CI Workflow Using GitHub Actions: A Step-By-Step Guide

Step 1: Create an Empty GitHub Repository

Step 2: Open your project in any text editor. Here I’m taking basic static HTML file with 1 heading and 1 paragraph. You can take anything.

Step 3: Open Git terminal and Push your project on the GitHub Repository using following steps.

For more detail explanation go through this article.

Step 4: Open the settings of your repository and go to Pages. From the source select GitHub Actions. This will allow us to deploy our code using GitHub Actions which will create CI workflow.

Step 5: Configure a Static HTML. This will generate a pre-build workflow for your static HTML file. GitHub provides in-built workflow, for my purposes I’ll select static HTML you can choose yours respective workflow.

Step 6: The following image is the workflow YAML file that will automate your process of deployment. You change this according to your needs but for now let’s just keep it as it is.

This files contains:

Step 7: Commit and push the file on your branch.

Step 8: From the above repo tabs go to Actions and check if your app is deployed on Github Pages or not. Open the deployment by clicking on the workflow name.

Step 9: Go to the link provided by GitHub this is where your HTML file is deployed.

Step 11: Now let’s check if CI workflow or not. First, pull your changes.

Automated CI/CD Workflow – FlowChart

Conclusion

In this article, we created a CI workflow involves defining workflows, jobs, and steps in a YAML configuration file. We effectively used available actions to automate deploy task and GitHub pages to deploy our project.

CI Workflow And Github Actions – FAQs

What Triggers A GitHub Actions Workflow?

It can be triggered by push to a branch, pull requests, scheduled runs, or even external events from other services.

What Are Jobs And Steps In A Workflow?

A workflow can consist of multiple jobs. Each job is made up of steps, which are the individual commands or actions that are executed.

How Can I Share My Own Custom Actions?

You can create your own custom Actions and share them with the community by publishing them as a public repository on GitHub.

How Can I Monitor And Debug My Workflows?

Visual workflow execution log allows you to track the progress of your workflows.

Are There Any Limitations On What I Can Achieve With GitHub Actions?

Compute resources and certain actions might require additional configuration or external tools


Article Tags :