Skip to content

feat(skip-ci): Add an action that skips CI for pushes changing only matching files - #187

Open
bitsandfoxes wants to merge 8 commits into
mainfrom
spire/skip-ci-action
Open

bitsandfoxes wants to merge 8 commits into
mainfrom
spire/skip-ci-action

Conversation

@bitsandfoxes

Copy link
Copy Markdown
Contributor

A push to a pull request that only touches Markdown, such as a CHANGELOG fix-up, still runs the full CI. A workflow's paths-ignore can't help: GitHub matches it against the whole pull request, so once a pull request changes code, every later push runs everything (actions/runner#2324).

skip-ci is a composite action that tells whether a push can skip the expensive jobs. A repo adds one small job that runs it and gates its build and test jobs on the action's skip output:

jobs:
  changes:
    runs-on: ubuntu-latest
    permissions:
      actions: read
      contents: read
    outputs:
      skip: ${{ steps.skip-ci.outputs.skip }}
    steps:
      - id: skip-ci
        uses: getsentry/github-workflows/skip-ci@<sha>
        with:
          paths: |
            **/*.md
            !package/**

  build:
    needs: [changes]
    if: ${{ needs.changes.outputs.skip != 'true' }}

sentry-unity does the same in its own workflow (getsentry/sentry-unity#2942). This action makes it available to every repo, with the file patterns configurable.

Does my push run CI?

Say you fix a typo in the CHANGELOG of your pull request. CI runs again unless it was green on your previous push and the new push changes only files that match paths.

flowchart TD
    push([You push a commit]) --> pr{To an open pull request?}
    pr -- no --> run([CI runs])
    pr -- yes --> green{CI green on the previous push?}
    green -- no --> run
    green -- yes --> files{Only files matching paths changed?}
    files -- no --> run
    files -- yes --> skip([Gated jobs skip])
    classDef accent fill:#2da44e,stroke:#1a7f37,color:#ffffff
    class skip accent
Loading

The details, all of which must hold for skip to be true. Anything else, including an API error, gives false, and CI runs:

  • Event: the event is pull_request with the synchronize action. push, workflow_dispatch, merge_group and pull_request_target always give false.
  • Green before: the same workflow has a successful run for the previous head, on the same branch of the same repository, that lists this pull request.
    • Runs for forks list no pull requests, so for those the branch and fork must match.
    • A run that skipped its jobs through this action counts too, because that run was itself checked against a head that passed.
  • History: the new head builds on the previous one. A force-push that dropped or rewrote commits gives false.
  • Changed files: between 1 and 299 files changed (the compare API lists at most 300), and every file matches paths. For a renamed file, its old name must match too.

paths takes one pattern per line and defaults to **/*.md. ** crosses folders, * and ? don't, and a leading ! takes files back out. The last pattern that matches a file decides.

The action never fails the job. When it skips, it writes the reason to the job summary.

The action's README covers the caveats:

  • Skipped matrix jobs report a single check under their unexpanded name, which matters for required status checks.
  • A skipped run doesn't re-test against a base branch that moved since the passing run.
  • The action needs gh and pwsh on the runner.

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor
Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.
📖 ✅ Custom dangerfile check: PR has a description
📖 ✅ Custom dangerfile check: PR title length is reasonable
📖 📊 Custom check: This PR changes 10 file(s)

Generated by 🚫 dangerJS against e8f25dd

@bitsandfoxes
bitsandfoxes marked this pull request as ready for review November 17, 2026 15:08

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want fixes drafted automatically? Bugbot Autofix can create code changes for findings. A team admin can enable Autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 4c355f5. Configure here.

Comment thread .github/workflows/script-tests.yml Resolved

@jpnurmi jpnurmi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Q: Could Re-run all jobs skip the skip? Might be nice to be able to run the full CI that way.

Comment thread skip-ci/scripts/match-paths.ps1 Resolved
@bitsandfoxes

Copy link
Copy Markdown
Contributor Author

Q: Could Re-run all jobs skip the skip? Might be nice to be able to run the full CI that way.

The action could read run_attempt and if it's greater than 1 it returns false? But that would be such an odd behaviour that you'd need to document. "Skips CI if changes only touched the .md files except when running twice?" CI already needs to be green in the commit before for this to kick in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants