This GitHub Action checks for changed files in a Git repository and validates them against a list of allowed files and folders. It is useful for enforcing file or folder boundaries in pull requests or CI/CD pipelines.
- Checks for changed files in a Git repository and validates them against a list of allowed files and folders
- Define a custom location of the Git repository
- Supports checking all files and folders in the directory
- The functionality is implemented in Python using the
pygit2library and fully tested by unit tests - The action can be used in GitHub Enterprise environments
| Name | Description | Required | Default |
|---|---|---|---|
| checked_location | Enter the location of the files, separated by ;. Example: src/;docs/test.txt;tests/test* |
true | |
| git_location | Path to the Git repository. | false | (current working directory) |
| check_all_files | Enables the check of all defined files and folders in the directory. | false | false |
| github_user_token | Define the used GitHub server user token for Github.com. | false | "" |
- name: Check changed files
uses: ZPascal/check-changed-files-action@v1
with:
checked_location: 'src/;docs/README.md'
git_location: './'
check_all_files: 'true'name: Check Changed Files
on:
pull_request:
paths:
- 'src/**'
- 'docs/**'
jobs:
check-changes:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Check changed files
id: test-changed-files
uses: ZPascal/check-changed-files-action@v1
with:
checked_location: 'src/;docs/README.md'
git_location: './'
check_all_files: 'true'
- name: Test
if: steps.test-changed-files.outputs.files_changed == 'true'
run: |
echo "Files changed: ${{ steps.test-changed-files.outputs.files_changed }}"- Logs info about changed files that are allowed or not allowed.
- Returns true/ false and reports if changed files are detected.
| Name | Description |
|---|---|
| files_changed | Returns true if changed files are detected and false by default. |
- Python 3.x
- pygit2
The check-changed-files-action is licensed under the Apache 2.0.