Script Valley
CI/CD with GitHub Actions
Advanced Workflow PatternsLesson 5.5

How to limit GitHub Actions costs with concurrency and skip conditions

concurrency group, cancel-in-progress, skip CI via commit message, paths-ignore, workflow_run trigger, cost optimization, redundant run cancellation

Cancelling Redundant Runs

Concurrency cancelling older workflow runs

Fast-moving branches accumulate queued workflow runs. Without concurrency control, every commit to a PR branch triggers a full run even if newer commits supersede it.

Concurrency Groups

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

Placing this at workflow level creates one concurrency group per workflow/branch combination. When a new run starts for the same group, the in-progress run is cancelled. This prevents wasted compute on obsolete commits. Remove cancel-in-progress: true on main branch deployments โ€” you do not want to cancel a production deploy mid-flight.

Skipping Runs via Commit Message

jobs:
  build:
    if: "!contains(github.event.head_commit.message, '[skip ci]')"
    runs-on: ubuntu-latest
    steps:
      - run: npm test

Path Filtering

on:
  push:
    paths-ignore:
      - '**.md'
      - 'docs/**'

paths-ignore prevents the workflow from running when only documentation files change โ€” a major cost saver for documentation-heavy repositories.

How to limit GitHub Actions costs with concurrency and skip conditions โ€” Advanced Workflow Patterns โ€” CI/CD with GitHub Actions โ€” Script Valley โ€” Script Valley