How can GitHub Actions improve your CI/CD Workflow?

Overview of CI/CD

Companies frequently attempt to deploy features as quickly as possible to stay competitive in the market. CI/CD is a set of tools and capabilities that automates the process of integrating, releasing, and deploying software, enabling development teams to deliver software to users in a timely, repeatable, and secure manner. By doing this, CI/CD supports the larger goal of agile methodology while supporting the DevOps approach of aligning development and operations teams.

Implementing CI is the first essential step for a developer to create high-quality code by automatically creating, testing, and integrating code revisions within a shared repository. By doing this, it is possible to add new features while causing the codebase as a whole as little disruption as possible and maintain stability and functionality.

Contrarily, CD automates the procedure for sending customers new codes. The code is automatically deployed to production after integration and testing, giving customers access to new features and advancements as soon as they become available. This eliminates the need for labor- and error-intensive manual deployment procedures. Teams may release new features and upgrades to users more frequently and with less work by automating the deployment process.

Together, CI and CD help teams work more efficiently, improve the quality of their code, and deliver new features to users faster.

How to Establish a CI/CD Pipeline?

blog-image

Introduction to Azure Web Apps

Azure web app is needed for developing, deploying, and expanding web applications, Microsoft Azure’s Azure Web App platform-as-a-service (PaaS) provides a reliable, affordable option that is fully managed. It features automated scaling capabilities, integrated security, support for custom domains, and a worldwide scale. By doing away with infrastructure management, it frees up developers to concentrate on building code and providing value to their consumers.

Creating an Azure Web App Service

Create a Web app resource with a distinct name under a relevant subscription and resource group with a particular location or App Service plan in the Azure portal. Because the web app’s URL will be name.azurewebsites.net, the name of the web app must be distinctive.

Select “your new web app” under Web apps. Select Get Publish profile from the Overview page, as seen in the accompanying screenshot.

blog-image

Overview of GitHub

GitHub is a  web-based platform used by developers to collaborate and share their code. GitHub serves as the primary repository for many open-source projects. Teams can collaborate more productively and effectively with the support of its strong version control, code review, and issue-tracking features.

Deploying a NodeJS Application to GitHub

You’ll produce an index.js file with a slightly altered version of the “HELLO WORLD!” example from [nodejs.org]. As soon as an Azure web app is launched, the code adds process.env.PORT as the port to listen on. A new repository can then be created by logging into GitHub.

The steps for publishing Node JS code to GitHub are as follows.

Initialize a local Git repository

git init

Commands to add files to the repository

git add index.js

git add package.json

git add package-lock.json

git add web.config

git commit -m “initial commit”

Command to add a git remote for pushing updates to the web app

git remote add [URL for remote repository]

Push your changes to Azure

git push origin master

GitHub Actions

Developers can use GitHub Actions to automate procedures (such as writing, testing, and deploying code) in response to specified events (such as a code push, a pull request, or a new release). Developers can create custom workflows by implementing a variety of pre-built actions or by creating their own actions using JavaScript or Docker. Since it can be used to automate procedures on a number of platforms and languages, GitHub Actions is a powerful tool for continuous integration and continuous deployment (CI/CD).

Setting up GitHub Actions

Click on Settings next to the name of your repository, navigate to the Security subsection, choose Secrets, and then click on Actions. Go to the New secret repository. By pasting the contents of the downloaded publish profile file into the secret’s value box and giving it the name AZURE_WEBAPP_PUBLISH_PROFILE, you can use app-level credentials. Then, click on the repository secret.

blog-image

Creating the Workflow

In the repository, click on Actions and select Deploy Node.js to Azure web App.

When a push is made to the master branch, the workflow shown in the next example shows how to build, test, and deploy the Node.js project to Azure App Service.

Set the name of the web app you generated as AZURE_WEBAPP_NAME in the workflow environment key. Change NODE_VERSION to the version you use if you use a Node.js version other than 14.x. Click commit modifications after selecting start commit.

blog-image

The build and deploy task will now begin. Build and deploy tasks are completed quickly, usually in less than a minute. Visit the Azure site now and select Browse or URL. It will now open https://yourwebapp.azurewebsites.net in the browser.

A webpage that displays “Hello World” appears, as shown in the following screenshot.

blog-image

Conclusion

Since its inception, GitHub Actions have completely changed the way developers handle workflow automation. It allows you to automate tedious software workflows like installing dependencies, running tests, detecting vulnerabilities, and deploying applications to a server. You can discover, create, and share actions to perform any job you’d like and combine actions in a completely customized workflow.

About the author

Jyotsna Dasari

I am grateful for the opportunity to be at the forefront of exploring chatbots, Node.js, and Angular 8 technologies. My passion for innovation drives me to share my insights and knowledge with others through blog posts that showcase emerging developments in this dynamic field.

Add comment

Welcome to Miracle's Blog

Our blog is a great stop for people who are looking for enterprise solutions with technologies and services that we provide. Over the years Miracle has prided itself for our continuous efforts to help our customers adopt the latest technology. This blog is a diary of our stories, knowledge and thoughts on the future of digital organizations.


For contacting Miracle’s Blog Team for becoming an author, requesting content (or) anything else please feel free to reach out to us at blog@miraclesoft.com.

Who we are?

Miracle Software Systems, a Global Systems Integrator and Minority Owned Business, has been at the cutting edge of technology for over 24 years. Our teams have helped organizations use technology to improve business efficiency, drive new business models and optimize overall IT.

Recent Posts