Menu

Stop paying for GitHub Actions runs nobody reads (and the cancel-in-progress mistake in most snippets)
📰

Stop paying for GitHub Actions runs nobody reads (and the cancel-in-progress mistake in most snippets)

DEV Community: cicd·robsonheals·13 days ago
#x5ybGO8N
#devtocicd#devto#dev#github#group
Reading 0:00
15s threshold

Push three commits to a pull request in five minutes and GitHub Actions runs your CI three times, in full. Only the last result matters. The other two burn minutes and hold runners the current run is waiting for.

I recently scanned the workflows of 139 popular JS/TS repos (1k–20k stars). 97 of 129 repos with push/PR workflows (75%) had at least one workflow with no concurrency group at all. So this isn't a beginner problem; it's in well-maintained projects too.

The fix

Add this at the top level of the workflow, next to on: :

concurrency : group : ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} cancel-in-progress : ${{ github.event_name == 'pull_request' }}

Enter fullscreen mode

Exit fullscreen mode

Runs in the same group are serialized. When a new one starts, the one in progress is cancelled if cancel-in-progress is true.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.