How to reduce costs for GitHub Actions?
GitHub Actions is my favorite CI/CD solution. Over the past year, I gradually switched all projects from CodePipeline to GitHub Actions. To this day, I enjoy the smooth user experience. However, GitHub-hosted runners quickly become a big item on GitHub’s monthly bill.
That’s why I will share how to reduce costs for GitHub Actions with Octolense by Sandro Volpicella and HyperEnv for GitHub Actions Runner made by Michael and me in the following.
Do you prefer watching a video instead of reading? Here you go!
Get insights into usage with Octolense
Analyzing usage is vital when it comes to cutting costs. The pricing model of GitHub-hosted runners is simple. You pay for every build minute depending on the operating system and number of CPUs. Here is an excerpt of the GitHub Actions pricing page.
Operating system | vCPUs | Per-minute rate (USD) |
---|---|---|
Linux | 2 | $0.008 |
Linux | 4 | $0.016 |
Linux | 8 | $0.032 |
Linux | 16 | $0.064 |
Linux | 32 | $0.128 |
Linux | 64 | $0.256 |
Windows | 2 | $0.016 |
Windows | 8 | $0.064 |
Windows | 16 | $0.128 |
Windows | 32 | $0.256 |
Windows | 64 | $0.512 |
macOS | 3 or 4 (M1 or Intel) | $0.08 |
macOS | 12 | $0.12 |
macOS | 6 (M1) | $0.16 |
How do you find out which repository consumes the most build minutes?
Unfortunately, GitHub only provides insights into the total amount of consumed build minutes.
The ability to generate a CSV report only helps a little to analyze spending.
Date,Product,SKU,Quantity,Unit Type,Price Per Unit ($),Multiplier,Owner,Repository Slug,Username,Actions Workflow,Notes |
Luckily, Sandro built Octolense, a simple-to-use and powerful tool to get insights into GitHub Actions usage. After connecting with GitHub, Octolense opens a dashboard showing the key metrics Billable Minutes, Paid Minutes, and Workflow Runs. Besides that, the dashboard lists the Top Cost Intensive Repositories.
And there is more. Opening the detail view of a repository unveils insights into successful and failed workflow runs.
Octolense provides valuable insights into the use of GitHub actions and allows you to identify the repositories where optimizing your CI/CD workflows will have the most significant impact.
Reduce costs with self-hosted runners by HyperEnv
By default, a workflow job runs on a GitHub-hosted runner. Alternatively, you can also use self-hosted runners to execute workflow jobs. Michael and I built HyperEnv for GitHub Actions Runner to make deploying self-hosted runners on AWS as easy as possible.
How does HyperEnv work? The following diagram illustrates the components automatically deployed to your AWS account within 10 minutes.
- GitHub sends a webhook event whenever a new job gets created.
- HyperEnv launches an EC2 instance with GitHub runner and build environments pre-installed.
- The GitHub runner executes the job.
- The EC2 instance terminates.
Switching from GitHub-hosted runners to HyperEnv reduces costs by at least 30%.
The following table shows a cost estimation for 20,000 build minutes running on t3.large
instances (2 vCPU, 8 GB memory, 25 GB volume) in us-east-1
.
Category | Description | Costs |
---|---|---|
HyperEnv for GitHub Actions Runner | $0.002 per vCPU and build minute | $80.00 |
EC2 instance | $0.0014 per build minute | $27.73 |
EBS volume | $0.0000019 per GB and build minute | $0.93 |
CloudWatch and others | $0.00001 per build minute | $0.20 |
Total Costs | HyperEnv for GitHub Actions Runner + AWS infrastructure | $110.66 |
That’s cost savings of 31% compared to GitHub-hosted runners.
Besides, many workflows do not require a machine with 2 vCPUs and 8 GB memory. By choosing a smaller instance type, you can reduce the costs for GitHub Actions executed on self-hosted runners even more.
Deploy HyperEnv for GitHub Actions Runner and reduce costs by at least 30%!
Summary
Gain insights into your GitHub actions usage with Octolense and reduce costs for GitHub Actions by switching from GitHub-hosted Runners to HyperEnv.
Do you have any other tips on how to reduce costs for GitHub Actions? Let me know!