DEV Community

Arowolo Ebine
Arowolo Ebine

Posted on

How to Implement a CI/CD pipeline with GitHub Actions in four simple steps In Your Repo.

How to Implement a CI/CD pipeline with GitHub Actions in your repository.

Continuous Integration / Continuous Delivery (CI/CD) has long been—and continues to be—the domain of DevOps experts. But with the introduction of native CI/CD to GitHub in 2019 via GitHub Actions, it’s easier than ever to bring CI/CD directly into your workflow right from your repository.

If you’re using Git, GitHub, and GitHub Actions to build a CI/CD pipeline, you should have confidence in your code.

I’m going to walk you through exactly how to build your own CI/CD pipeline, right from your repository on GitHub.

A CI pipeline runs when code changes and should make sure all of your changes work with the rest of the code when it’s integrated. It should also compile your code, run tests, and check that it’s functional. A CD pipeline goes one step further and deploys the built code into production.

There are plenty of guided options with pre-built CI workflows you can leverage, per your technology requirements. But you can also build your own CI workflow from scratch if you want to.

To begin building your CI/CD pipeline, open the GitHub Actions tab in your repository’s top navigation bar. You should see a list of CI/CD and workflow automation templates that match the technology of your project.

For your project, you'll leverage a few different CI/CD workflows to test, build, stage, and deploy your code. These include:

  1. A development workflow: This workflow runs through a few different jobs whenever a pull request is opened, edited, synchronized, or reopened. These jobs include setting up Node, installing npm packages and dependencies, running npm test, and cycling through a number of lint jobs too

  2. ** A CodeQL Analysis workflow:** This workflow runs a series of CodeQL security tests on our code after we merge it to the main branch to ensure there are no known vulnerabilities. This involves YAML.file. It’s super simple, but effective and something I’d highly recommend.

  3. A deployment workflow: This workflow deploys any UI component changes to our production website.

  4. A release and build workflow: This workflow runs tests and enforces lint after releasing code changes to Docker and building the application. It also deploys the final code to our production environment, cuts a release using a similar structure to the automated release notes, bundles the site into a container and publishes to ghcr. From there, it bumps the version number and tag in the repository.

Top comments (0)