---
title: "Simple trick to save environment and money when using GitHub Actions"
description: "GitHub Actions keeps running workflows for outdated pull request commits until they finish or fail."
url: "https://swe.quest/articles/simple-trick-to-save-environment-and-money-when-using-github-actions-14be6ffdb9f9e911"
canonical: "https://turso.tech/blog/simple-trick-to-save-environment-and-money-when-using-github-actions"
source: "Turso"
published: "2024-07-30"
difficulty: "medium"
kind: "How-to"
reading_minutes: 2
tags: ["ci-cd","cost-optimization"]
---

# Simple trick to save environment and money when using GitHub Actions

A post on [Turso](https://swe.quest/sources/turso.md), published 2024-07-30, 2 min read, How-to. Original: [https://turso.tech/blog/simple-trick-to-save-environment-and-money-when-using-github-actions](https://turso.tech/blog/simple-trick-to-save-environment-and-money-when-using-github-actions)

## Summary

GitHub Actions keeps running workflows for outdated pull request commits until they finish or fail. That wastes runner time, money on private repos, and quota on open source ones. Adding a \`concurrency\` block keyed on workflow name and PR number (falling back to the ref) with \`cancel-in-progress: true\` makes GitHub cancel stale runs when a PR is updated. In the first week after this change, 56 runs were cancelled in the LibSQL repository.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [CI/CD](https://swe.quest/tags/ci-cd.md) (Reliability & operations)
- [Cost optimization](https://swe.quest/tags/cost-optimization.md) (Reliability & operations)

## Prerequisites

- GitHub Actions workflows ([easy posts on CI/CD](https://swe.quest/tags/ci-cd.md?difficulty=easy))

## Keywords

GitHub Actions, LibSQL, Turso

## Related posts

- [How we tripled max concurrent jobs to boost performance of GitHub Actions](https://swe.quest/articles/how-we-tripled-max-concurrent-jobs-to-boost-performance-of-github-actions-9d54244cd033cdac.md): GitHub Engineering · 2022-09-16 · Medium · 5 min read · Performance engineering, Scaling, CI/CD, Caching
  GitHub Actions on GitHub Enterprise Server went from 2,200 to 7,000 max concurrent jobs on 96-core machines between GHES 3.2 and 3.6 through three main fixes.
- [Building GitHub with Ruby and Rails](https://swe.quest/articles/building-github-with-ruby-and-rails-99851966c067c871.md): GitHub Engineering · 2023-04-06 · Medium · 5 min read · Ruby, Refactoring & migrations, CI/CD, Deployment, Open source
  GitHub's ~2M-line Rails monolith upgrades to the latest Rails main-branch commit every week via a scheduled GitHub Actions workflow that opens an automated PR, runs all builds, and ships the next day.
- [How GitHub uses GitHub Actions and Actions larger runners to build and test GitHub.com](https://swe.quest/articles/how-github-uses-github-actions-and-actions-larger-runners-to-build-and-test-915368ba99ad3985.md): GitHub Engineering · 2023-09-26 · Medium · 8 min read · CI/CD, Developer productivity, Identity & auth, Scaling
  GitHub moved CI for GitHub.com to GitHub Actions on larger runners, peaking at about 4,500 concurrent 32-core runners, 15,000 jobs per hour and 150,000 cores.
- [AI coding has made CI a bottleneck, so we reworked ours to keep up](https://swe.quest/articles/ai-coding-has-made-ci-a-bottleneck-so-we-reworked-ours-to-keep-up-1594c74d280c863b.md): Linear · 2026-09-21 · Medium · 8 min read · CI/CD, Developer productivity, Cost optimization, TypeScript, Performance engineering
  Linear cut pull request CI wait time from over 6 minutes to about 5 and halved runner time per test, even as its test suites nearly quadrupled.
- [Incident Report: November 25th, 2025](https://swe.quest/articles/incident-report-november-25th-2025-0f5ac3667ca5f9ba.md): Railway · 2025-11-25 · Medium · 3 min read · Incidents & postmortems, Resilience, Scheduling
  Slow GitHub API calls (about 4x normal p95 latency) during peak hours backed up Railway's Temporal-based task queue, causing workers to run out of memory and crash in a cascading thundering-herd pattern as surviving and newly started workers were overwhelmed by the backlog.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
