CI/CD is a concept that integrates Continuous Integration, Continuous Delivery and Continuous Deployment as a method to have the code built, tested and deployed whenever a new change occurs or an event is triggered.
There are multiple tools to do CI/CD, such as GitLab CI, Jenkins, TeamCity and CircleCI, among others. This post will focus on GitHub Actions as an option to do CI/CD, but also to execute additional tasks, without aiming for it to be a comparison with other tools.
Continuous Everything is a term used, without it being a formal definition, to represent the fact that GitHub Actions can provide additional tasks that are not necessarily covered inside the definition of CI/CD. And it can provide additional automation for the development and management teams.
The GitHub Actions Process
- GitHub Actions is a workflow automation tool composed of a workflow file, which is a YAML file located in the .github/workflows/ folder at the root of your repository.
- Each workflow file has a set of jobs to be run. These jobs are executed in parallel by default but can run sequentially if specified.
- Every job runs on a different virtual machine; therefore, no data is shared between jobs unless configured to do so.
- Per job, there’s a series of steps that define a specific task to be taken. These steps can be a script in bash, PowerShell, or Python or a specific action.
Why should you consider GitHub Actions as an option?
Currently, many projects already have a CI/CD pipeline in place, and other tools can perform similar tasks. In case you wonder, here are two reasons why you should consider trying out GitHub Actions in your organization or in personal projects.
There are many actions that have been created to perform different tasks, and all of these are available in the Marketplace. All actions are open source and free, and to use them, you only need to invoke the action on the desired job.
Some of the actions are written by the companies that created the tool, such as Microsoft, AWS, or Terraform, while others are created by individuals. Be careful about what actions are being used and what data is required.
This is a list of popular actions that might seem interesting, such as an action to run CodeGuru in your codebase, to run GitHub Actions on your tests, or to set up Terraform and analyze and apply your template.
This is an example of a setup that uses an action to checkout the code, and another one to set up node to then run npm commands:
GitHub Actions is free for public repositories. So, if it’s your own repository or one you like, you can fork it into your repo and start using Actions for free, with no additional configuration needed other than setting up your YAML files, and no limitations or costs associated.
Additionally, GitHub allows users to have free private repositories, and you can add GitHub Actions to them with a limit of 2,000 run minutes per month, with no credit card required.
GitHub Actions runs on machines that can be self-hosted or use GitHub-hosted runners. These can run on Linux, Windows or macOS; the only difference between OS is that each one has a minute multiplier:
This means that if you have a set of UI Tests executed on Linux, macOS and Windows, and each run takes 2 minutes, you will be discounted 26 minutes per run from your monthly free limit. Therefore, although not limited to, Linux runs should be preferred over other configurations.
GitHub-hosted runners are automatically cleaned after every run; therefore, you don’t have to worry about cleaning your environment or deleting resources created inside the runner. If needed be, GitHub provides actions to save artifacts or cache data between jobs.
One of the best ways to understand the tool is to explore some of the ways companies are using it currently. Here’s a list of interesting applications of GitHub Actions:
- Review a Pull Request to match the expected format: Semantic Pull Request
- Automatically upload legal software details (SBOM) to a newly created release. Upload Release Asset
- Every morning at 8 a.m., check if there are new browser versions available and commit information about new versions automatically. Update Browser Version
- Continuous Integration Process: Build and Run end-to-end tests: CI
- When a git tag is created with a version number, create a release on GitHub: Create Release
Microsoft Graph Documentation:
- Assign to author: When an issue is created, automatically assign it to the person who created the page in the documentation. Assign To Author
- Review if a PR has merge conflicts: Conflicting PR
Cypress Example TodoMVC:
- An example that runs Cypress tests on a local server using GitHub Actions with the official Cypress Action: Todo-MVC E2E Tests
Jazzer.js: Run tests against MacOS, Ubuntu and Windows simultaneously: Jazzer.js Tests
Want to learn more?
Check out these links and courses for more information:
GitHub Actions are a relatively new and upcoming option for DevOps. There is active development and a big community using it, given that GitHub is commonly used for open-source development.
Consider adding a simple action to any of your existing repositories, or fork any repository and play with the actions; it’s free and you don’t have to worry about resource consumption and associated costs.