Skip to content
You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?
file

GitHub Action

Match against glob

v1

Match against glob

file

Match against glob

Matches filenames against glob patterns. Uses minimatch

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Match against glob

uses: kurnev/match-against-glob-action@v1

Learn more about this action in kurnev/match-against-glob-action

Choose a version

Match against glob action

This action tests whether filenames match against provided glob patterns. Useful to run another steps only if needed files were changed. Similar to GitLab changes feature which is available for a single job in a workflow. Uses minimatch internally.

Inputs

  • Required filenames: Filenames split by comma. E.g. src/index.js,package.json,./tests/index.test.js
  • Required patterns: Glob patterns as a YAML list. E.g. services/*-service/**/*,packages/**/*

Outputs

  • match: 'true' if at least one file matches. 'false' otherwise
  • files: Lists all files matching the patterns

Example usages

Get files changed in pull request

- uses: octokit/request-action@v2.x
  id: get_files
  with:
    route: GET /repos/{owner}/{repo}/pulls/{pull_number}/files
    owner: meshokteam
    repo: meshok
    pull_number: ${{ github.event.pull_request.number }} 
  env:
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: kurnev/match-against-glob-action@v1
  id: match
  with:
    filenames: ${{ join(fromJson(steps.get_files.outputs.data).*.filename) }}
    patterns: 'services/nuxt/**/*,packages/shared/**/*'
- name: Run unit tests
  if: ${{ steps.match.outputs.match == 'true' }}
  uses: ./.github/actions/unit-tests/
  ...

Conventional Changelog Action is MIT licensed.

Collaboration

If you have questions or issues, please open an issue!