Home

Awesome

Ubuntu Mac OS Windows Public workflows that use this action.

Codacy Badge CI Update release version.

<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->

All Contributors

<!-- ALL-CONTRIBUTORS-BADGE:END -->

verify-changed-files

Verify that certain files or directories did or did not change during the workflow execution.

[!NOTE]

Features

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@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@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@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 :star:

Buy me a coffee

Inputs

<!-- AUTO-DOC-INPUT:START - Do not remove or modify this section -->
- uses: tj-actions/verify-changed-files@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-changed` 
    # or `fail-if-unchanged` is set to 
    # `true`. 
    # Type: string
    fail-message: ''

    # File/Directory names to check for 
    # uncommited changes. 
    # Type: string
    files: ''

    # Separator used to split the 
    # `files` input 
    # Type: string
    # Default: "\n"
    files-separator: ''

    # Indicates whether to match files 
    # in `.gitignore` 
    # Type: 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 `false` 
    # Type: boolean
    # Default: "true"
    quotepath: ''

    # Indicates whether to read `.gitignore`. 
    # The `.gitignore` file will be 
    # ignored if set to `false`. 
    # Overrides `match-gitignore-files` 
    # Type: 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: ''

<!-- AUTO-DOC-INPUT:END -->

Outputs

<!-- AUTO-DOC-OUTPUT:START - Do not remove or modify this section -->
OUTPUTTYPEDESCRIPTION
<a name="output_changed_files"></a>changed_filesstringList of changed files
<a name="output_files_changed"></a>files_changedstringBoolean indicating that files have <br>changed.
<!-- AUTO-DOC-OUTPUT:END -->

Known Limitation

[!WARNING]

Report Bugs

Report bugs at https://github.com/tj-actions/verify-changed-files/issues.

If you are reporting a bug, please include:

Contributors ✨

Thanks goes to these wonderful people (emoji key):

<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --> <!-- prettier-ignore-start --> <!-- markdownlint-disable --> <table> <tbody> <tr> <td align="center" valign="top" width="14.28%"><a href="https://github.com/max-kahnt-keylight"><img src="https://avatars.githubusercontent.com/u/79849575?v=4?s=100" width="100px;" alt="Max Kahnt"/><br /><sub><b>Max Kahnt</b></sub></a><br /><a href="https://github.com/tj-actions/verify-changed-files/commits?author=max-kahnt-keylight" title="Documentation">📖</a></td> <td align="center" valign="top" width="14.28%"><a href="https://wllm.no"><img src="https://avatars.githubusercontent.com/u/1223410?v=4?s=100" width="100px;" alt="William Killerud"/><br /><sub><b>William Killerud</b></sub></a><br /><a href="https://github.com/tj-actions/verify-changed-files/commits?author=wkillerud" title="Code">💻</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/Minecraftschurli"><img src="https://avatars.githubusercontent.com/u/23388022?v=4?s=100" width="100px;" alt="Minecraftschurli"/><br /><sub><b>Minecraftschurli</b></sub></a><br /><a href="https://github.com/tj-actions/verify-changed-files/commits?author=Minecraftschurli" title="Code">💻</a> <a href="https://github.com/tj-actions/verify-changed-files/commits?author=Minecraftschurli" title="Documentation">📖</a> <a href="https://github.com/tj-actions/verify-changed-files/commits?author=Minecraftschurli" title="Tests">⚠️</a></td> <td align="center" valign="top" width="14.28%"><a href="https://stefanhoth.com"><img src="https://avatars.githubusercontent.com/u/45467?v=4?s=100" width="100px;" alt="Stefan Hoth"/><br /><sub><b>Stefan Hoth</b></sub></a><br /><a href="https://github.com/tj-actions/verify-changed-files/commits?author=stefanhoth" title="Code">💻</a></td> <td align="center" valign="top" width="14.28%"><a href="https://home.boidol.dev/"><img src="https://avatars.githubusercontent.com/u/652404?v=4?s=100" width="100px;" alt="Raphael Boidol"/><br /><sub><b>Raphael Boidol</b></sub></a><br /><a href="https://github.com/tj-actions/verify-changed-files/commits?author=boidolr" title="Documentation">📖</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/Larspolo"><img src="https://avatars.githubusercontent.com/u/11822478?v=4?s=100" width="100px;" alt="Lars"/><br /><sub><b>Lars</b></sub></a><br /><a href="https://github.com/tj-actions/verify-changed-files/commits?author=Larspolo" title="Code">💻</a> <a href="https://github.com/tj-actions/verify-changed-files/commits?author=Larspolo" title="Tests">⚠️</a> <a href="https://github.com/tj-actions/verify-changed-files/commits?author=Larspolo" title="Documentation">📖</a></td> </tr> </tbody> </table> <!-- markdownlint-restore --> <!-- prettier-ignore-end --> <!-- ALL-CONTRIBUTORS-LIST:END -->

This project follows the all-contributors specification. Contributions of any kind welcome!