Skip to content

brettcannon/check-for-changed-files

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

check-for-changed-files Action

An action to check that PRs have changed certain files.

Inputs

file-pattern

Required The glob pattern for the file(s) that must be changed by the PR.

The glob patterns are matched using minimatch with {dot: true} options. As well, multiple lines in the input are supported, and each line is treated as its own glob pattern. E.g.:

file-pattern: |
  package.json
  package-lock.json

acts as two patterns: package.json and package-lock.json. Success occurs if any of the patterns match.

prereq-pattern

A pre-requisite glob pattern that, if specified, will cause the action to proceed only if the pattern matches. If a match isn't found then the action is considered successful.

See the notes about patterns for file-pattern for details on how matching occurs and the flexibility in specifying the pattern.

skip-label

The name of a label to forcibly skip the changed file check.

failure-message

The message to emit when the check fails. All other inputs can be specified in the message using ${} syntax, e.g. ${file-pattern} for the file-pattern input. All values will be quoted for easy identification of any whitespace.

token

A GitHub auth token to use for private repositories. Falls back to anonymous access if not provided. Usually you want to use ${{ secrets.GITHUB_TOKEN }} for this.

Example usage (for requiring a news entry file)

E.g. for use with scriv:

on:
  pull_request:
    types:
      # On by default if you specify no types.
      - "opened"
      - "reopened"
      - "synchronize"
      # For `skip-label` only.
      - "labeled"
      - "unlabeled"

jobs:
  ...
    ...
    steps:
      ...
      - name: "Check for news entry"
        uses: brettcannon/check-for-changed-files@v1
        with:
          file-pattern: "changelog.d/*.rst"
          skip-label: "skip news"
          failure-message: "Missing a news file in ${file-pattern}; please add one or apply the ${skip-label} label to the pull request"

About

Action to check that PRs have changed certain files

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published