GitHub Action
List Changed Files
This GitHub Action returns a list of files changed by a pull request or a push, and a list of files matching a given pattern list.
on:
push:
pull_request:
jobs:
check:
runs-on: ubuntu-latest
steps:
- id: changed-files
name: Check changed files
uses: knu/changed-files@v1
with:
paths: |
**/*.{json,js,ts,[cm]js}
!**/*.d.ts
- name: Show changed files
run: |
echo "Changed files:"
echo "${{ steps.changed-files.outputs.changed_files }}" | sed 's/^/ /'
echo "Matched files:"
echo "${{ steps.changed-files.outputs.matched_files }}" | sed 's/^/ /'
- name: Run if any file matching paths is changed
if: steps.changed-files.outputs.matched_files != ''
run: |
echo "Do something"
- name: Run if a specific file is changed
if: contains(fromJson(steps.changed-files.outputs.changed_files_json), 'package.json')
run: |
echo "Do something"
-
paths
(string)A list of path patterns to match against changed files in the
.gitignore
syntax.Matching is performed using the ignore library.
-
token
(string)The GitHub token to use for fetching the list of changed files.
Default:
${{ github.token }}
-
changed_files
A multi-line string containing the list of changed files.
-
changed_files_json
A JSON string containing the list of changed files.
-
matched_files
A multi-line string containing the list of changed files matching
paths
patterns. Empty (""
) ifpaths
is not given. -
matched_files_json
A JSON string containing the list of changed files matching
paths
patterns. Empty ("[]"
) ifpaths
is not given.
Copyright (c) 2024 Akinori MUSHA.
Licensed under the 2-clause BSD license. See LICENSE.txt
for details.
Visit the GitHub Repository for the latest information.