GitHub - tj-actions/verify-changed-files: :octocat: Github action to verify file changes that occur during the workflow execution. (original) (raw)
Verify that certain files or directories did or did not change during the workflow execution.
Note
- This action only detects files that have pending uncommitted changes generated during the workflow execution, for running a specific step when a file changes in a pull request or based on a pushed commit
See: https://github.com/tj-actions/changed-files instead
Features
- Fast execution (0-2 seconds on average).
- Easy to debug.
- Scales to large repositories.
- Supports all platforms (Linux, MacOS, Windows).
- GitHub-hosted runners support
- GitHub Enterprise Server support.
- self-hosted runners support.
- Boolean output for detecting uncommitted changes.
- List all files that changed during the workflow execution.
- Detect changes to track and untracked files.
- Restrict change detection to a subset of files:
- Using Glob pattern matching.
* Supports Globstar.
* Supports brace expansion.
* Supports negation.
- Using Glob pattern matching.
Usage
... steps: - uses: actions/checkout@v4
- name: Change text file
run: |
echo "Modified" > new.txt
- name: Change file in directory
run: |
echo "Changed" > test_directory/new.txt
- name: Verify Changed files
uses: tj-actions/verify-changed-files@a1c6acee9df209257a246f2cc6ae8cb6581c1edf # v20
id: verify-changed-files
with:
files: |
*.txt
test_directory
action.yml
**/*.{jpeg,py}
!*.sql
- name: Run step only when any of the above files change.
if: steps.verify-changed-files.outputs.files_changed == 'true'
env:
CHANGED_FILES: ${{ steps.verify-changed-files.outputs.changed_files }}
run: |
echo "Changed files: $CHANGED_FILES"
# Outputs: "Changed files: new.txt test_directory/new.txt"Using the contains function.
... - name: Verify Changed files uses: tj-actions/verify-changed-files@a1c6acee9df209257a246f2cc6ae8cb6581c1edf # v20 id: verify-changed-files with: files: | new.txt test_directory
- name: Perform action when test_directory changes
if: contains(steps.verify-changed-files.outputs.changed_files, 'test_directory')
run: |
echo "test_directory has changed."Get all unstaged (tracked/untracked) files
... - name: Verify Changed files uses: tj-actions/verify-changed-files@a1c6acee9df209257a246f2cc6ae8cb6581c1edf # v20 id: verify-changed-files
- name: List all changed tracked and untracked files
env:
CHANGED_FILES: ${{ steps.verify-changed-files.outputs.changed_files }}
run: |
echo "Changed files: $CHANGED_FILES"If you feel generous and want to show some extra appreciation:
Support this project with a ⭐
Inputs
uses: tj-actions/verify-changed-files@a1c6acee9df209257a246f2cc6ae8cb6581c1edf # v20 id: verify-changed-files with:
Indicates whether to fail if
files have changed.
Type: boolean
Default: "false"
fail-if-changed: ''
Indicates whether to fail if
no files have changed.
Type: boolean
Default: "false"
fail-if-unchanged: ''
Message to display when
fail-if-changedor
fail-if-unchangedis set totrue.Type: string
fail-message: ''
File/Directory names to check for
uncommited changes.
Type: string
files: ''
Separator used to split the
filesinputType: string
Default: "\n"
files-separator: ''
Indicates whether to match files
in
.gitignoreType: boolean
Default: "false"
match-gitignore-files: ''
Relative path under GITHUB_WORKSPACE to
the repository
Type: string
Default: "."
path: ''
Use non-ASCII characters to match
files and output the filenames
completely verbatim by setting this
to
falseType: boolean
Default: "true"
quotepath: ''
Indicates whether to read
.gitignore.The
.gitignorefile will beignored if set to
false.Overrides
match-gitignore-filesType: boolean
Default: "false"
read-gitignore: ''
Apply sanitization to output filenames
before being set as output.
Type: boolean
Default: "true"
safe_output: ''
Output string separator.
Type: string
Default: " "
separator: ''
Outputs
| OUTPUT | TYPE | DESCRIPTION |
|---|---|---|
| changed_files | string | List of changed files |
| files_changed | string | Boolean indicating that files have changed. |
- Free software: MIT license
Known Limitation
Warning
- Using characters like
\n,%,.and\ras output string separators would be URL encoded
Report Bugs
Report bugs at https://github.com/tj-actions/verify-changed-files/issues.
If you are reporting a bug, please include:
- Your operating system name and version.
- Any details about your workflow that might be helpful in troubleshooting.
- Detailed steps to reproduce the bug.
Contributors ✨
Thanks goes to these wonderful people (emoji key):
This project follows the all-contributors specification. Contributions of any kind welcome!
