GithubHelp home page GithubHelp logo

tj-actions / changed-files Goto Github PK

View Code? Open in Web Editor NEW
1.5K 7.0 171.0 32.63 MB

:octocat: Github action to retrieve all (added, copied, modified, deleted, renamed, type changed, unmerged, unknown) files and directories.

License: MIT License

JavaScript 0.36% TypeScript 99.64%
github changed-file modified actions modified-files github-actions workflows ci-cd change-detection monorepo

changed-files's Introduction

Ubuntu Mac OS Windows Public workflows that use this action.

Codacy Badge CI Update release version.

All Contributors

changed-files

Effortlessly track all changed files and directories relative to a target branch, the current branch (preceding commit or the last remote commit), multiple branches, or custom commits returning relative paths from the project root using this GitHub action.

Note

Table of contents

Features ๐Ÿš€

  • Fast execution, averaging 0-10 seconds.
  • Leverages either Github's REST API or Git's native diff to determine changed files.
  • Facilitates easy debugging.
  • Scales to handle large/mono repositories.
  • Supports Git submodules.
  • Supports merge queues for pull requests.
  • Generates escaped JSON output for running matrix jobs based on changed files.
  • Lists changed directories.
    • Limits matching changed directories to a specified maximum depth.
    • Optionally excludes the current directory.
  • Writes outputs to a designated .txt or .json file for further processing.
  • Restores deleted files to their previous location or a newly specified location.
  • Supports fetching a fixed number of commits which improves performance.
  • Compatible with all platforms (Linux, MacOS, Windows).
  • Supports GitHub-hosted runners.
  • Supports GitHub Enterprise Server.
  • Supports self-hosted runners.
  • Lists all files and directories that have changed:
    • Between the current pull request branch and the last commit on the target branch.
    • Between the last commit and the current pushed change.
    • Between the last remote branch commit and the current HEAD.
  • Restricts change detection to a subset of files and directories:

And many more...

Usage ๐Ÿ’ป

Important

  • Push Events: When configuring actions/checkout, make sure to set fetch-depth to either 0 or 2, depending on your use case.
  • Mono Repositories: To avoid pulling the entire branch history, you can utilize the default actions/checkout's fetch-depth of 1 for pull_request events.
  • Quoting Multiline Inputs: Avoid using single or double quotes for multiline inputs. The value is already a string separated by a newline character. Refer to the Examples section for more information.
  • Credentials Persistence: If fetch-depth is not set to 0, make sure to set persist-credentials to true when configuring actions/checkout.
  • Matching Files and Folders: To match all files and folders under a directory, this requires a globstar pattern e.g. dir_name/** which matches any number of subdirectories and files.

Visit the discussions for more information or create a new discussion for usage-related questions.

On pull_request ๐Ÿ”€

Detect changes to all files in a Pull request relative to the target branch or since the last pushed commit.

Using local .git directory ๐Ÿ“

name: CI

on:
  pull_request:
    branches:
      - main

jobs:
  # ------------------------------------------------------------------------------------------------------------------------------------------------
  # Event `pull_request`: Compare the last commit of the main branch or last remote commit of the PR branch -> to the current commit of a PR branch.
  # ------------------------------------------------------------------------------------------------------------------------------------------------
  changed_files:
    runs-on: ubuntu-latest  # windows-latest || macos-latest
    name: Test changed-files
    steps:
      - uses: actions/checkout@v4

      # -----------------------------------------------------------------------------------------------------------
      # Example 1
      # -----------------------------------------------------------------------------------------------------------
      - name: Get changed files
        id: changed-files
        uses: tj-actions/changed-files@v44
        # To compare changes between the current commit and the last pushed remote commit set `since_last_remote_commit: true`. e.g
        # with:
        #   since_last_remote_commit: true 

      - name: List all changed files
        env:
          ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
        run: |
          for file in ${ALL_CHANGED_FILES}; do
            echo "$file was changed"
          done

      # -----------------------------------------------------------------------------------------------------------
      # Example 2
      # -----------------------------------------------------------------------------------------------------------
      - name: Get all changed markdown files
        id: changed-markdown-files
        uses: tj-actions/changed-files@v44
        with:
          # Avoid using single or double quotes for multiline patterns
          files: |
             **.md

      - name: List all changed files markdown files
        if: steps.changed-markdown-files.outputs.any_changed == 'true'
        env:
          ALL_CHANGED_FILES: ${{ steps.changed-markdown-files.outputs.all_changed_files }}
        run: |
          for file in ${ALL_CHANGED_FILES}; do
            echo "$file was changed"
          done

      # -----------------------------------------------------------------------------------------------------------
      # Example 3
      # -----------------------------------------------------------------------------------------------------------
      - name: Get all test, doc and src files that have changed
        id: changed-files-yaml
        uses: tj-actions/changed-files@v44
        with:
          files_yaml: |
            doc:
              - '**.md'
              - docs/**
            test:
              - test/**
              - '!test/**.md'
            src:
              - src/**
          # Optionally set `files_yaml_from_source_file` to read the YAML from a file. e.g `files_yaml_from_source_file: .github/changed-files.yml`

      - name: Run step if test file(s) change
        # NOTE: Ensure all outputs are prefixed by the same key used above e.g. `test_(...)` | `doc_(...)` | `src_(...)` when trying to access the `any_changed` output.
        if: steps.changed-files-yaml.outputs.test_any_changed == 'true'  
        env:
          TEST_ALL_CHANGED_FILES: ${{ steps.changed-files-yaml.outputs.test_all_changed_files }}
        run: |
          echo "One or more test file(s) has changed."
          echo "List all the files that have changed: $TEST_ALL_CHANGED_FILES"
      
      - name: Run step if doc file(s) change
        if: steps.changed-files-yaml.outputs.doc_any_changed == 'true'
        env:
          DOC_ALL_CHANGED_FILES: ${{ steps.changed-files-yaml.outputs.doc_all_changed_files }}
        run: |
          echo "One or more doc file(s) has changed."
          echo "List all the files that have changed: $DOC_ALL_CHANGED_FILES"

      # -----------------------------------------------------------------------------------------------------------
      # Example 4
      # -----------------------------------------------------------------------------------------------------------
      - name: Get changed files in the docs folder
        id: changed-files-specific
        uses: tj-actions/changed-files@v44
        with:
          files: docs/*.{js,html}  # Alternatively using: `docs/**`
          files_ignore: docs/static.js

      - name: Run step if any file(s) in the docs folder change
        if: steps.changed-files-specific.outputs.any_changed == 'true'
        env:
          ALL_CHANGED_FILES: ${{ steps.changed-files-specific.outputs.all_changed_files }}
        run: |
          echo "One or more files in the docs folder has changed."
          echo "List all the files that have changed: $ALL_CHANGED_FILES"

Using Github's API :octocat:

name: CI

on:
  pull_request:
    branches:
      - main

jobs:
  # -------------------------------------------------------------
  # Event `pull_request`: Returns all changed pull request files.
  # --------------------------------------------------------------
  changed_files:
    # NOTE:
    # - This is limited to pull_request* events and would raise an error for other events.
    # - A maximum of 3000 files can be returned.
    # - For more flexibility and no limitations see "Using local .git directory" above.

    runs-on: ubuntu-latest  # windows-latest || macos-latest
    name: Test changed-files
    permissions:
      pull-requests: read

    steps:
      - name: Get changed files
        id: changed-files
        uses: tj-actions/changed-files@v44

      - name: List all changed files
        env:
          ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
        run: |
          for file in ${ALL_CHANGED_FILES}; do
            echo "$file was changed"
          done

On push โฌ†๏ธ

Detect changes to files made since the last pushed commit.

name: CI

on:
  push:
    branches:
      - main

jobs:
  # -------------------------------------------------------------
  # Using GitHub's API is not supported for push events
  # -------------------------------------------------------------
  # 
  # ----------------------------------------------------------------------------------------------
  # Using local .git history
  # ----------------------------------------------------------------------------------------------
  # Event `push`: Compare the preceding remote commit -> to the current commit of the main branch 
  # ----------------------------------------------------------------------------------------------
  changed_files:
    runs-on: ubuntu-latest  # windows-latest || macos-latest
    name: Test changed-files
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0  # OR "2" -> To retrieve the preceding commit.

      - name: Get changed files
        id: changed-files
        uses: tj-actions/changed-files@v44
      # NOTE: `since_last_remote_commit: true` is implied by default and falls back to the previous local commit.

      - name: List all changed files
        env:
          ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
        run: |
          for file in ${ALL_CHANGED_FILES}; do
            echo "$file was changed"
          done
      ...

Other supported events :electron:

To access more examples, navigate to the Examples section.

If you feel generous and want to show some extra appreciation:

Support this project with a โญ

Buy me a coffee

Important

  • When using files_yaml* inputs:
    • All keys must start with a letter or _ and contain only alphanumeric characters, -, or _.

      For example, test or test_key or test-key or _test_key are all valid choices.

Inputs โš™๏ธ

- uses: tj-actions/changed-files@v44
  id: changed-files
  with:
    # Github API URL.
    # Type: string
    # Default: "${{ github.api_url }}"
    api_url: ''

    # Specify a different base commit 
    # SHA or branch used for 
    # comparing changes 
    # Type: string
    base_sha: ''

    # Exclude changes outside the current 
    # directory and show path names 
    # relative to it. NOTE: This 
    # requires you to specify the 
    # top-level directory via the `path` 
    # input. 
    # Type: boolean
    # Default: "true"
    diff_relative: ''

    # Output unique changed directories instead 
    # of filenames. NOTE: This returns 
    # `.` for changed files located 
    # in the current working directory 
    # which defaults to `$GITHUB_WORKSPACE`. 
    # Type: boolean
    # Default: "false"
    dir_names: ''

    # Include only directories that have 
    # been deleted as opposed to 
    # directory names of files that 
    # have been deleted in the 
    # `deleted_files` output when `dir_names` is 
    # set to `true`. 
    # Type: boolean
    # Default: "false"
    dir_names_deleted_files_include_only_deleted_dirs: ''

    # Exclude the current directory represented 
    # by `.` from the output 
    # when `dir_names` is set to 
    # `true`. 
    # Type: boolean
    # Default: "false"
    dir_names_exclude_current_dir: ''

    # File and directory patterns to 
    # include in the output when 
    # `dir_names` is set to `true`. 
    # NOTE: This returns only the 
    # matching files and also the 
    # directory names. 
    # Type: string
    dir_names_include_files: ''

    # Separator used to split the 
    # `dir_names_include_files` input 
    # Type: string
    # Default: "\n"
    dir_names_include_files_separator: ''

    # Limit the directory output to 
    # a maximum depth e.g `test/test1/test2` 
    # with max depth of `2` 
    # returns `test/test1`. 
    # Type: string
    dir_names_max_depth: ''

    # Escape JSON output.
    # Type: boolean
    # Default: "true"
    escape_json: ''

    # Exclude changes to submodules.
    # Type: boolean
    # Default: "false"
    exclude_submodules: ''

    # Fail when the initial diff 
    # fails. 
    # Type: boolean
    # Default: "false"
    fail_on_initial_diff_error: ''

    # Fail when the submodule diff 
    # fails. 
    # Type: boolean
    # Default: "false"
    fail_on_submodule_diff_error: ''

    # Fetch additional history for submodules.
    # Type: boolean
    # Default: "false"
    fetch_additional_submodule_history: ''

    # Depth of additional branch history 
    # fetched. NOTE: This can be 
    # adjusted to resolve errors with 
    # insufficient history. 
    # Type: string
    # Default: "25"
    fetch_depth: ''

    # Maximum number of retries to 
    # fetch missing history. 
    # Type: string
    # Default: "20"
    fetch_missing_history_max_retries: ''

    # File and directory patterns used 
    # to detect changes (Defaults to the entire repo if unset). NOTE: 
    # Multiline file/directory patterns should not 
    # include quotes. 
    # Type: string
    files: ''

    # Source file(s) used to populate 
    # the `files` input. 
    # Type: string
    files_from_source_file: ''

    # Separator used to split the 
    # `files_from_source_file` input. 
    # Type: string
    # Default: "\n"
    files_from_source_file_separator: ''

    # Ignore changes to these file(s). 
    # NOTE: Multiline file/directory patterns should 
    # not include quotes. 
    # Type: string
    files_ignore: ''

    # Source file(s) used to populate 
    # the `files_ignore` input 
    # Type: string
    files_ignore_from_source_file: ''

    # Separator used to split the 
    # `files_ignore_from_source_file` input 
    # Type: string
    # Default: "\n"
    files_ignore_from_source_file_separator: ''

    # Separator used to split the 
    # `files_ignore` input 
    # Type: string
    # Default: "\n"
    files_ignore_separator: ''

    # YAML used to define a 
    # set of file patterns to 
    # ignore changes 
    # Type: string
    files_ignore_yaml: ''

    # Source file(s) used to populate 
    # the `files_ignore_yaml` input. Example: https://github.com/tj-actions/changed-files/blob/main/test/changed-files.yml 
    # Type: string
    files_ignore_yaml_from_source_file: ''

    # Separator used to split the 
    # `files_ignore_yaml_from_source_file` input 
    # Type: string
    # Default: "\n"
    files_ignore_yaml_from_source_file_separator: ''

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

    # YAML used to define a 
    # set of file patterns to 
    # detect changes 
    # Type: string
    files_yaml: ''

    # Source file(s) used to populate 
    # the `files_yaml` input. Example: https://github.com/tj-actions/changed-files/blob/main/test/changed-files.yml 
    # Type: string
    files_yaml_from_source_file: ''

    # Separator used to split the 
    # `files_yaml_from_source_file` input 
    # Type: string
    # Default: "\n"
    files_yaml_from_source_file_separator: ''

    # Include `all_old_new_renamed_files` output. Note this 
    # can generate a large output 
    # See: #501. 
    # Type: boolean
    # Default: "false"
    include_all_old_new_renamed_files: ''

    # Output list of changed files 
    # in a JSON formatted string 
    # which can be used for 
    # matrix jobs. Example: https://github.com/tj-actions/changed-files/blob/main/.github/workflows/matrix-example.yml 
    # Type: boolean
    # Default: "false"
    json: ''

    # Output changed files in a 
    # format that can be used 
    # for matrix jobs. Alias for 
    # setting inputs `json` to `true` 
    # and `escape_json` to `false`. 
    # Type: boolean
    # Default: "false"
    matrix: ''

    # Apply the negation patterns first. 
    # NOTE: This affects how changed 
    # files are matched. 
    # Type: boolean
    # Default: "false"
    negation_patterns_first: ''

    # Split character for old and 
    # new renamed filename pairs. 
    # Type: string
    # Default: " "
    old_new_files_separator: ''

    # Split character for old and 
    # new filename pairs. 
    # Type: string
    # Default: ","
    old_new_separator: ''

    # Directory to store output files.
    # Type: string
    # Default: ".github/outputs"
    output_dir: ''

    # Output renamed files as deleted 
    # and added files. 
    # Type: boolean
    # Default: "false"
    output_renamed_files_as_deleted_and_added: ''

    # Specify a relative path under 
    # `$GITHUB_WORKSPACE` to locate 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: ''

    # Recover deleted files.
    # Type: boolean
    # Default: "false"
    recover_deleted_files: ''

    # Recover deleted files to a 
    # new destination directory, defaults to 
    # the original location. 
    # Type: string
    recover_deleted_files_to_destination: ''

    # File and directory patterns used 
    # to recover deleted files, defaults 
    # to the patterns provided via 
    # the `files`, `files_from_source_file`, `files_ignore` and 
    # `files_ignore_from_source_file` inputs or all deleted 
    # files if no patterns are 
    # provided. 
    # Type: string
    recover_files: ''

    # File and directory patterns to 
    # ignore when recovering deleted files. 
    # Type: string
    recover_files_ignore: ''

    # Separator used to split the 
    # `recover_files_ignore` input 
    # Type: string
    # Default: "\n"
    recover_files_ignore_separator: ''

    # Separator used to split the 
    # `recover_files` input 
    # Type: string
    # Default: "\n"
    recover_files_separator: ''

    # Apply sanitization to output filenames 
    # before being set as output. 
    # Type: boolean
    # Default: "true"
    safe_output: ''

    # Split character for output strings.
    # Type: string
    # Default: " "
    separator: ''

    # Specify a different commit SHA 
    # or branch used for comparing 
    # changes 
    # Type: string
    sha: ''

    # Get changed files for commits 
    # whose timestamp is older than 
    # the given time. 
    # Type: string
    since: ''

    # Use the last commit on 
    # the remote branch as the 
    # `base_sha`. Defaults to the last 
    # non-merge commit on the target 
    # branch for pull request events 
    # and the previous remote commit 
    # of the current branch for 
    # push events. 
    # Type: boolean
    # Default: "false"
    since_last_remote_commit: ''

    # Skip initially fetching additional history 
    # to improve performance for shallow 
    # repositories. NOTE: This could lead 
    # to errors with missing history. 
    # It's intended to be used 
    # when you've fetched all necessary 
    # history to perform the diff. 
    # Type: boolean
    # Default: "false"
    skip_initial_fetch: ''

    # GitHub token used to fetch 
    # changed files from Github's API. 
    # Type: string
    # Default: "${{ github.token }}"
    token: ''

    # Get changed files for commits 
    # whose timestamp is earlier than 
    # the given time. 
    # Type: string
    until: ''

    # Use POSIX path separator `/` 
    # for output file paths on 
    # Windows. 
    # Type: boolean
    # Default: "false"
    use_posix_path_separator: ''

    # Force the use of Github's 
    # REST API even when a 
    # local copy of the repository 
    # exists 
    # Type: boolean
    # Default: "false"
    use_rest_api: ''

    # Write outputs to the `output_dir` 
    # defaults to `.github/outputs` folder. NOTE: 
    # This creates a `.txt` file 
    # by default and a `.json` 
    # file if `json` is set 
    # to `true`. 
    # Type: boolean
    # Default: "false"
    write_output_files: ''

Useful Acronyms ๐Ÿงฎ

Acronym Meaning
A Added
C Copied
M Modified
D Deleted
R Renamed
T Type changed
U Unmerged
X Unknown

Important

  • When using files_yaml* inputs:
    • it's required to prefix all outputs with the key to ensure that the correct outputs are accessible.

      For example, if you use test as the key, you can access outputs like added_files, any_changed, and so on by prefixing them with the key test_added_files or test_any_changed etc.

Outputs ๐Ÿ“ค

OUTPUT TYPE DESCRIPTION
added_files string Returns only files that are
Added (A).
added_files_count string Returns the number of added_files
all_changed_and_modified_files string Returns all changed and modified
files i.e. a combination of
(ACMRDTUX)
all_changed_and_modified_files_count string Returns the number of all_changed_and_modified_files
all_changed_files string Returns all changed files i.e.
a combination of all added,
copied, modified and renamed files
(ACMR)
all_changed_files_count string Returns the number of all_changed_files
all_modified_files string Returns all changed files i.e.
a combination of all added,
copied, modified, renamed and deleted
files (ACMRD).
all_modified_files_count string Returns the number of all_modified_files
all_old_new_renamed_files string Returns only files that are
Renamed and lists their old
and new names. NOTE: This
requires setting include_all_old_new_renamed_files to true.
Also, keep in mind that
this output is global and
wouldn't be nested in outputs
generated when the *_yaml_* input
is used. (R)
all_old_new_renamed_files_count string Returns the number of all_old_new_renamed_files
any_changed string Returns true when any of
the filenames provided using the
files* or files_ignore* inputs have changed. This
defaults to true when no
patterns are specified. i.e. includes a combination of all added, copied, modified and renamed files (ACMR).
any_deleted string Returns true when any of
the filenames provided using the
files* or files_ignore* inputs have been deleted.
This defaults to true when
no patterns are specified. (D)
any_modified string Returns true when any of
the filenames provided using the
files* or files_ignore* inputs have been modified.
This defaults to true when
no patterns are specified. i.e.
includes a combination of all added, copied, modified, renamed, and deleted files (ACMRD).
changed_keys string Returns all changed YAML keys
when the files_yaml input is
used. i.e. key that contains
any path that has either
been added, copied, modified, and
renamed (ACMR)
copied_files string Returns only files that are
Copied (C).
copied_files_count string Returns the number of copied_files
deleted_files string Returns only files that are
Deleted (D).
deleted_files_count string Returns the number of deleted_files
modified_files string Returns only files that are
Modified (M).
modified_files_count string Returns the number of modified_files
modified_keys string Returns all modified YAML keys
when the files_yaml input is
used. i.e. key that contains
any path that has either
been added, copied, modified, and
deleted (ACMRD)
only_changed string Returns true when only files
provided using the files* or files_ignore* inputs
have changed. i.e. includes a combination of all added, copied, modified and renamed files (ACMR).
only_deleted string Returns true when only files
provided using the files* or files_ignore* inputs
have been deleted. (D)
only_modified string Returns true when only files
provided using the files* or files_ignore* inputs
have been modified. (ACMRD).
other_changed_files string Returns all other changed files
not listed in the files
input i.e. includes a combination
of all added, copied, modified
and renamed files (ACMR).
other_changed_files_count string Returns the number of other_changed_files
other_deleted_files string Returns all other deleted files
not listed in the files
input i.e. a combination of
all deleted files (D)
other_deleted_files_count string Returns the number of other_deleted_files
other_modified_files string Returns all other modified files
not listed in the files
input i.e. a combination of
all added, copied, modified, and
deleted files (ACMRD)
other_modified_files_count string Returns the number of other_modified_files
renamed_files string Returns only files that are
Renamed (R).
renamed_files_count string Returns the number of renamed_files
type_changed_files string Returns only files that have
their file type changed (T).
type_changed_files_count string Returns the number of type_changed_files
unknown_files string Returns only files that are
Unknown (X).
unknown_files_count string Returns the number of unknown_files
unmerged_files string Returns only files that are
Unmerged (U).
unmerged_files_count string Returns the number of unmerged_files

Versioning ๐Ÿท๏ธ

This GitHub Action follows the principles of Semantic Versioning for versioning releases.

The format of the version string is as follows:

  • major: indicates significant changes or new features that may not be backward compatible.

  • minor: indicates minor changes or new features that are backward compatible.

  • patch: indicates bug fixes or other small changes that are backward compatible.

Examples ๐Ÿ“„

Get all changed files in the current branch
...
    - name: Get changed files
      id: changed-files
      uses: tj-actions/changed-files@v44
...
Get all changed files without escaping unsafe filename characters
...
    - name: Get changed files
      id: changed-files
      uses: tj-actions/changed-files@v44
      with:
        safe_output: false # set to false because we are using an environment variable to store the output and avoid command injection.

    - name: List all added files
      env:
        ADDED_FILES: ${{ steps.changed-files.outputs.added_files }}
      run: |
        for file in ${ADDED_FILES}; do
          echo "$file was added"
        done
...
Get all changed files and use a comma separator
...
    - name: Get all changed files and use a comma separator in the output
      id: changed-files
      uses: tj-actions/changed-files@v44
      with:
        separator: ","
...

See inputs for more information.

Get all changed files and list all added files
...
    - name: Get changed files
      id: changed-files
      uses: tj-actions/changed-files@v44

    - name: List all added files
      env:
        ADDED_FILES: ${{ steps.changed-files.outputs.added_files }}
      run: |
        for file in ${ADDED_FILES}; do
          echo "$file was added"
        done
...

See outputs for a list of all available outputs.

Get all changed files and optionally run a step if a file was modified
...
    - name: Get changed files
      id: changed-files
      uses: tj-actions/changed-files@v44

    - name: Run a step if my-file.txt was modified
      if: contains(steps.changed-files.outputs.modified_files, 'my-file.txt')
      run: |
        echo "my-file.txt file has been modified."
...

See outputs for a list of all available outputs.

Get all changed files and write the outputs to a txt file
...

   - name: Get changed files and write the outputs to a Txt file
     id: changed-files-write-output-files-txt
     uses: tj-actions/changed-files@v44
     with:
       write_output_files: true

   - name: Verify the contents of the .github/outputs/added_files.txt file
     run: |
       cat .github/outputs/added_files.txt
...
Get all changed files and write the outputs to a json file
...
   - name: Get changed files and write the outputs to a JSON file
     id: changed-files-write-output-files-json
     uses: tj-actions/changed-files@v44
     with:
       json: true
       write_output_files: true

   - name: Verify the contents of the .github/outputs/added_files.json file
     run: |
       cat .github/outputs/added_files.json
...
Get all changed files using a list of files
...
    - name: Get changed files
      id: changed-files
      uses: tj-actions/changed-files@v44
      with:
        files: |
          my-file.txt
          *.sh
          *.png
          !*.md
          test_directory/**
          **/*.sql
...

See inputs for more information.

Get all changed files using a list of files and take action based on the changes
...
    - name: Get changed files
      id: changed-files-specific
      uses: tj-actions/changed-files@v44
      with:
        files: |
          my-file.txt
          *.sh
          *.png
          !*.md
          test_directory/**
          **/*.sql

    - name: Run step if any of the listed files above change
      if: steps.changed-files-specific.outputs.any_changed == 'true'
      run: |
        echo "One or more files listed above has changed."

    - name: Run step if only the files listed above change
      if: steps.changed-files-specific.outputs.only_changed == 'true'
      run: |
        echo "Only files listed above have changed."

    - name: Run step if any of the listed files above is deleted
      if: steps.changed-files-specific.outputs.any_deleted == 'true'
      env:
        DELETED_FILES: ${{ steps.changed-files-specific.outputs.deleted_files }}
      run: |
        for file in ${DELETED_FILES}; do
          echo "$file was deleted"
        done

    - name: Run step if all listed files above have been deleted
      if: steps.changed-files-specific.outputs.only_deleted == 'true'
      env:
        DELETED_FILES: ${{ steps.changed-files-specific.outputs.deleted_files }}
      run: |
        for file in ${DELETED_FILES}; do
          echo "$file was deleted"
        done
...

See outputs for a list of all available outputs.

Get all changed files using a source file or list of file(s) to populate to files input
...
    - name: Get changed files using a source file or list of file(s) to populate to files input.
      id: changed-files-specific-source-file
      uses: tj-actions/changed-files@v44
      with:
        files_from_source_file: test/changed-files-list.txt
...

See inputs for more information.

Get changed files using a source file or list of file(s) to populate to files input and optionally specify more files
...
    - name: Get changed files using a source file or list of file(s) to populate to files input and optionally specify more files.
      id: changed-files-specific-source-file-and-specify-files
      uses: tj-actions/changed-files@v44
      with:
        files_from_source_file: |
          test/changed-files-list.txt
        files: |
          test.txt
...

See inputs for more information.

Get all changed files using a different SHA
...
    - name: Get changed files using a different SHA
      id: changed-files
      uses: tj-actions/changed-files@v44
      with:
        sha: ${{ github.event.pull_request.head.sha }}
...

See inputs for more information.

Get all changed files using a different base SHA
...
    - name: Get changed files using a different base SHA
      id: changed-files
      uses: tj-actions/changed-files@v44
      with:
        base_sha: ${{ github.event.pull_request.base.sha }}
...

See inputs for more information.

Get all changed files between the previous tag and the current tag
...
on:
  push:
    tags:
      - 'v*'

jobs:
  release:
    name: Release
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4
        with:
          fetch-depth: 0

      - name: Get changed files
        id: changed-files
        uses: tj-actions/changed-files@v44

      - name: List changed files
        env:
          ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
        run: |
          echo "List all the files that have changed: $ALL_CHANGED_FILES"

      - name: Get changed files in the .github folder
        id: changed-files-specific
        uses: tj-actions/changed-files@v44
        with:
          files: .github/**

      - name: Run step if any file(s) in the .github folder change
        if: steps.changed-files-specific.outputs.any_changed == 'true'
        env:
          ALL_CHANGED_FILES: ${{ steps.changed-files-specific.outputs.all_changed_files }}
        run: |
          echo "One or more files in the .github folder has changed."
          echo "List all the files that have changed: $ALL_CHANGED_FILES"
...

See inputs for more information.

Get all changed files for a repository located in a different path
...
    - name: Checkout into dir1
      uses: actions/checkout@v4
      with:
        fetch-depth: 0
        path: dir1

    - name: Run changed-files with defaults in dir1
      id: changed-files-for-dir1
      uses: tj-actions/changed-files@v44
      with:
        path: dir1

    - name: List all added files in dir1
      env:
        ADDED_FILES: ${{ steps.changed-files-for-dir1.outputs.added_files }}
      run: |
        for file in ${ADDED_FILES}; do
          echo "$file was added"
        done
...

See inputs for more information.

Get all changed files with non-รคลกฤ‡ฤฏรญ characters i.e (Filename in other languages)
...
    - name: Run changed-files with quotepath disabled
      id: changed-files-quotepath
      uses: tj-actions/changed-files@v44
      with:
        quotepath: "false"

    - name: Run changed-files with quotepath disabled for a specified list of file(s)
      id: changed-files-quotepath-specific
      uses: tj-actions/changed-files@v44
      with:
        files: test/test-รจ.txt
        quotepath: "false"
...

See inputs for more information.

Get all changed files using the last successful commit of the base branch
  • Push event
    ...
          - name: Get branch name
            id: branch-name
            uses: tj-actions/branch-names@v6
    
          - uses: nrwl/nx-set-shas@v3
            id: last_successful_commit_push
            with:
              main-branch-name: ${{ steps.branch-name.outputs.current_branch }} # Get the last successful commit for the current branch.
              workflow-id: 'test.yml'
    
          - name: Run changed-files with the commit of the last successful test workflow run
            id: changed-files-base-sha-push
            uses: tj-actions/changed-files@v44
            with:
              base_sha: ${{ steps.last_successful_commit_push.outputs.base }}
    ...
  • Pull request events
    ...
          - name: Get branch name
            id: branch-name
            uses: tj-actions/branch-names@v5
    
          - uses: nrwl/nx-set-shas@v3
            id: last_successful_commit_pull_request
            with:
              main-branch-name: ${{ steps.branch-name.outputs.base_ref_branch }} # Get the last successful commit on the master or main branch
              workflow_id: 'test.yml'
    
          - name: Run changed-files with the commit of the last successful test workflow run on the main branch
            id: changed-files-base-sha-pull-request
            uses: tj-actions/changed-files@v44
            with:
              base_sha: ${{ steps.last_successful_commit_pull_request.outputs.base }}
    ...

Warning

This setting overrides the commit sha used by setting since_last_remote_commit to true. It is recommended to use either solution that works for your use case.

See inputs for more information.

Get all changed files but only return the directory names
...
    - name: Run changed-files with dir_names
      id: changed-files-dir-names
      uses: tj-actions/changed-files@v44
      with:
        dir_names: "true"
...

See inputs for more information.

Get all changed files and return JSON formatted outputs
...
    - name: Run changed-files with JSON output
      id: changed-files-json
      uses: tj-actions/changed-files@v44
      with:
        json: "true"
...

See inputs for more information.

Get all changed files by commits pushed in the past
...
    - name: Get changed-files since 2022-08-19
      id: changed-files-since
      uses: tj-actions/changed-files@v44
      with:
        since: "2022-08-19"

    - name: Get changed-files until 2022-08-20
      id: changed-files-until
      uses: tj-actions/changed-files@v44
      with:
        until: "2022-08-20"
...

See inputs for more information.

Real-world usage ๐ŸŒ

Open source projects ๐Ÿ“ฆ

And many more...

Scalability Example ๐Ÿ“ˆ

image

Important Notice โš ๏ธ

Important

  • Spaces in file names can introduce bugs when using bash loops. See: #216 However, this action will handle spaces in file names, with a recommendation of using a separator to prevent any hidden issues.

    Screen Shot 2021-10-23 at 9 37 34 AM

Migration guide ๐Ÿ”„

With the switch from using grep's Extended regex to match files to the natively supported workflow glob pattern matching syntax introduced in v13 you'll need to modify patterns used to match files.

...
      - name: Get specific changed files
        id: changed-files-specific
        uses: tj-actions/changed-files@v24
        with:
          files: |
-            \.sh$
-            .(sql|py)$
-            ^(dir1|dir2)
+            **/*.{sh,sql,py}
+            {dir1,dir2}/**

Credits ๐Ÿ‘

This package was created with cookiecutter-action.

Report Bugs ๐Ÿ›

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

If you are reporting a bug, please include:

  • Your operating system name and version.
  • All essential details about your workflow that might be helpful in troubleshooting. (NOTE: Ensure that you include full log outputs with debugging enabled)
  • Detailed steps to reproduce the bug.

Contributors โœจ

Thanks goes to these wonderful people (emoji key):

Josh Soref
Josh Soref

๐Ÿ“–
Nick Landers
Nick Landers

๐Ÿ’ป
Krasimir Nikolov
Krasimir Nikolov

๐Ÿ’ป ๐Ÿ“–
Ivan Pizhenko
Ivan Pizhenko

๐Ÿ’ป ๐Ÿ“–
talva-tr
talva-tr

๐Ÿ’ป
Ikko Ashimine
Ikko Ashimine

๐Ÿ“–
James
James

๐Ÿ“–
James Cheng
James Cheng

๐Ÿ“–
Masaya Suzuki
Masaya Suzuki

๐Ÿ’ป
fagai
fagai

๐Ÿ“–
Constantine Peresypkin
Constantine Peresypkin

๐Ÿ’ป
Mathieu Dupuy
Mathieu Dupuy

๐Ÿ“–
Joe Moggridge
Joe Moggridge

๐Ÿ“–
Charles Santos
Charles Santos

๐Ÿ’ป
Kostiantyn Korniienko
Kostiantyn Korniienko

๐Ÿ“–
Logan Pulley
Logan Pulley

๐Ÿ’ป
Kenji Miyake
Kenji Miyake

๐Ÿ’ป
adonisgarciac
adonisgarciac

๐Ÿ’ป ๐Ÿ“–
Chiel Fernhout
Chiel Fernhout

๐Ÿ“–
Alberto Perdomo
Alberto Perdomo

๐Ÿ“–
Arthur
Arthur

๐Ÿ› ๐Ÿ’ป
Rodrigo Fior Kuntzer
Rodrigo Fior Kuntzer

๐Ÿ’ป โš ๏ธ ๐Ÿ›
Aleksey Levenstein
Aleksey Levenstein

๐Ÿ“–
Daniel Hill
Daniel Hill

๐Ÿ“–
KeisukeYamashita
KeisukeYamashita

๐Ÿ“–
Aravind
Aravind

๐Ÿ’ป ๐Ÿ›

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

changed-files's People

Contributors

actions-user avatar albertoperdomo2 avatar allcontributors[bot] avatar benhammondmusic avatar cfernhout avatar codesculpture avatar dan-hill2802 avatar dependabot[bot] avatar deronnax avatar eltociear avatar ivanpizhenko avatar jackton1 avatar joeovo avatar jorgectf avatar jsoref avatar keisukeyamashita avatar kras4ooo avatar levenleven avatar lpulley avatar massongit avatar pkit avatar renovate-bot avatar renovate[bot] avatar repo-ranger[bot] avatar thyarles avatar tj-actions-bot avatar tonyejack1 avatar v0lantis avatar wushujames avatar zamiell avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

changed-files's Issues

[Feature] any_changed doesn't capture changes due to deleting files

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug?

I would expect any_changed to be true when there is a deleted file. It looks like any changed doesn't take deleted files into account.

To Reproduce

Delete a file in the specified directory and then check the any_changed flag.

What OS are you seeing the problem on?

ubuntu-latest or ubuntu-20.04

Expected behavior?

If there is anything listed for "All changed files" that the any_changed flag would be true.

Relevant log output

Checking for file changes: "automated-testing-gaps.md"...  
  Checking for file changes: "AutomatedTests"...
  Added files: 
  Copied files: 
  Deleted files: AutomatedTests/SettingsMonitorTests.swift
  Modified files: 
  Renamed files: 
  Type Changed files: 
  Unmerged files: 
  Unknown files: 
  All changed files: ffm/AutomatedTests/SettingsMonitorTests.swift
  All modified files: 
  Input files: automated-testing-gaps.md AutomatedTests
  Matching modified files: 
  Non Matching modified files: UserPreferences.m AppDelegate.m

Anything else?

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

[Feature] fetch HEAD without tags

Is this feature missing in the latest version?

  • I'm using the latest release

Is your feature request related to a problem? Please describe.

Using this on a monorepo with a lot of tags, it will cause minor slowness and more output over time (there are already hundreds of tags).

Describe the solution you'd like?

Tags don't seem to be necessary, so fetching can most likely be performed with --no-tags.

https://github.com/tj-actions/changed-files/blob/main/entrypoint.sh#L52

Describe alternatives you've considered?

No response

Anything else?

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

[Feature] Add support for `any_deleted` and `only_deleted` boolean output.

Is your feature request related to a problem? Please describe.

The current changed file detection via only_deleted and any_deleted doesn't include deleted files which makes it tough to detect files that were deleted.

Describe the solution you'd like?

Proposes Solution

Adding two new boolean outputs should help with detecting file deletion.

      - name: Run step when any listed file has been deleted
        if: steps.changed-files.outputs.any_deleted == "true"
        run: |
          for file in "${{ steps.changed-files.outputs.deleted_files }}"; do
            echo "$file was deleted"
          done

      - name: Run step when all listed files have been deleted
        if: steps.changed-files.outputs.only_deleted == "true"
        run: |
          for file in "${{ steps.changed-files.outputs.deleted_files }}"; do
            echo "$file was deleted"
          done

Describe alternatives you've considered?

No response

Anything else?

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

[BUG] Spaces in file names are not handled correctly

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug?

If you have spaces in your file names and you provide a custom separator (eg. separator: ",") all spaces are replaced by the separator and the results sorted.

To Reproduce

  1. On a repo containing the paths:
  • embeds/general 412874536418279426/read-me-1 899830563651854336.json
  • Test 1/Test 1.json
  1. Running
- id: json_changes
  uses: tj-actions/[email protected]
  with:
      files: |
        .json$
      separator: ","

- name: List modified files
  run: |
    echo ${{ steps.json_changes.outputs.all_modified_files }}
  1. Sees the result of:
    1.json,1/Test,412874536418279426/read-me-1,899830563651854336.json,Test,embeds/general

What OS are you seeing the problem on?

ubuntu-latest or ubuntu-20.04

Expected behavior?

I expect:
embeds/general 412874536418279426/read-me-1 899830563651854336.json,Test 2/Test 1.json

Relevant log output

No response

Anything else?

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

[BUG] Error: xargs: unmatched single quote

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug?

I get the following error sometimes:

xargs: unmatched single quote; by default quotes are special to xargs unless you use the -0 option

To Reproduce

I haven't had time to try to reproduce it locally. I'm first posting here to check if this is a known issue or if someone else already had it before I spend more time troubleshooting it (I'm a bash novice).

What OS are you seeing the problem on?

ubuntu-latest or ubuntu-20.04

Expected behavior?

There should be no errors.

Relevant log output

Run tj-actions/changed-files@2f8c46f9d79d979656108f4fc4414c378ee4abed
  with:
    files: ^transform/snowflake-dbt/.*
  
    base_sha: 01f529cacb2dff32b9a54cf946dce1c74c039a5a
    sha: c6e8af0e7208d28653aab87352c9d5f81cc7742b
    token: ***
    separator:  
  env:
    SNOWSQL_ACCOUNT: ***
    SNOWSQL_USER: ***
    SNOWSQL_PWD: ***
    SNOWSQL_WAREHOUSE: dbt_ci_wh
changed-files
  Getting HEAD info...
  From https://github.com/voiapp/data-pipelines
   * [new branch]        master     -> master
   * [new branch]        master     -> origin/master
  Retrieving changes between 01f529cacb2dff32b9a54cf946dce1c74c039a5a (master) โ†’ c6e8af0e7208d28653aab87352c9d5f81cc7742b (backfill_MRS_vehicle_not_available)
  Checking for file changes: "^transform/snowflake-dbt/.*"...
  Added files: 
  Copied files: 
  Deleted files: 
  Modified files: transform/snowflake-dbt/models/analytics/magic_ride_session.sql transform/snowflake-dbt/models/model/engineering/user_experience/start_ride_attempt.sql
  Renamed files: 
  Type Changed files: 
  Unmerged files: 
  Unknown files: 
  All changed files: transform/snowflake-dbt/models/analytics/magic_ride_session.sql transform/snowflake-dbt/models/model/engineering/user_experience/start_ride_attempt.sql
  All modified files: transform/snowflake-dbt/models/analytics/magic_ride_session.sql transform/snowflake-dbt/models/model/engineering/user_experience/start_ride_attempt.sql
  xargs: unmatched single quote; by default quotes are special to xargs unless you use the -0 option
  Error: Process completed with exit code 1.

Anything else?

Great project, thanks for maintaining it! Very useful.

For security reasons, I have to hardcode the commit SHAs of external GitHub Actions. The one I'm using for this report is 2f8c46f, which is the equivalent of v9.3.

Screenshot of the error: image

Code of Conduct

  • I agree to follow this project's Code of Conduct

Add support for watching a subset of files.

Is your feature request related to a problem? Please describe.
Add support for checking a subset of files that have changed relative to the default branch.

   - name: Get all changed files
     id: changed_files
     uses: ...
     with:
       files: ...

   - name: Run step
     if: steps.changed_files.outputs == 'true'

Setting remote URL breaks other steps that are using it

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug?

It seems that:
git remote set-url origin "https://${INPUT_TOKEN}@github.com/${GITHUB_REPOSITORY}"
is permanently breaking the next steps we have in the workflow that depends on it.

After executing the script origin should be set to it's original value instead of keeping it with INPUT_TOKEN

To Reproduce

  1. Add changed-file step
  2. Check in next step that origin is permanently modified which may break other scripts.

What OS are you seeing the problem on?

all

Expected behavior?

I would expect to not have modified origin at the end of script execution

Relevant log output

Our other scripts depend on git origin string comparison for security reasons, having token forced is making them fail.

Anything else?

I work around that issue by adding extra step that is resetting changes:

- name: Fix get changed files origin
        run: |
          git remote set-url origin "https://github.com/${GITHUB_REPOSITORY}"

Code of Conduct

  • I agree to follow this project's Code of Conduct

[Feature] Make it easier to exclude files

Is this feature missing in the latest version?

  • I'm using the latest release

Is your feature request related to a problem? Please describe.

Right now files can be used to easily match files, essentially an "allow" list. For example, you can match any file which begins with a path, like ^path/to/directory. However, it's not easy to exclude files. For example, if I wanted to match on all files in the path/to/directory except files which end with .md.

Describe the solution you'd like?

It may be easiest to accept another input, such as exclude-files, which will simply be negated versions of the provided GREP regular expressions. For example, to exclude all files ending with .md you could do exclude-files: \.md$

Describe alternatives you've considered?

See also: #264 -- which if implemented could invalidate this ticket.

Anything else?

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

[Feature] Support the same filter syntax as GitHub Workflows

Is this feature missing in the latest version?

  • I'm using the latest release

Is your feature request related to a problem? Please describe.

This action would be more intuitive and easier to use if it supported the same file filtering syntax as GitHub Workflows support natively. I realize the reason it does not is because it's easier to just accept the input that is used natively by the underlying bash commands. But I'm curious if this is something that could eventually be implemented.

Describe the solution you'd like?

Use syntax like foo/**/bar instead of ^foo/.*/bar, or **/*.md instead of or \.md$. Exclusion rules could either be supported with ! rules, or in a separate input (e.g. exclude-files).

Describe alternatives you've considered?

No response

Anything else?

https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#filter-pattern-cheat-sheet

Code of Conduct

  • I agree to follow this project's Code of Conduct

[Feature] Improve documentation

Is this feature missing in the latest version?

  • I'm using the latest release

Is your feature request related to a problem? Please describe.

The examples are hard to follow and understand

Describe the solution you'd like?

I'll like a more detailed example that highlights each use case.

Describe alternatives you've considered?

No response

Anything else?

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

[BUG] Deleted files not detected

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug?

I am using the action as follows, but when I delete files in "mydir", they are not appearing in the summary.
e.g. I delete mydir/hello.txt
The deleted file is missing from the list "Checking for file changes" and "Deleted files:"
This happens every time.

To Reproduce

    steps:
      - name: Get latest code
        uses: actions/checkout@v2
        with:
          fetch-depth: 0

      - name: Get changed files
        id: changed-files
        uses: tj-actions/[email protected]
        with:
          files: |
            mydir/**

What OS are you seeing the problem on?

ubuntu-latest or ubuntu-20.04

Expected behavior?

Deleted files should list the files that were deleted.

Relevant log output

Run tj-actions/[email protected]
  with:
    files: mydir/**
  
    token: ***
    separator:  
    sha: XXXXX
  env:
    AWS_ACCESS_KEY_ID: ***
    AWS_SECRET_ACCESS_KEY: ***
    AWS_S3_BUCKET: ***
    AWS_REGION: ***
changed-files
  Getting HEAD info...
  Retrieving changes between XXX (master) โ†’ XXXX (master)
  Checking for file changes: "mydir/d"...
  Checking for file changes: "mydir/gulpfile.js"...
  Checking for file changes: "mydir/images"...
  Checking for file changes: "mydir/slider"...
  Checking for file changes: "mydir/style"...
  Added files: 
  Copied files: 
  Deleted files: 
  Modified files: 
  Renamed files: 
  Type Changed files: 
  Unmerged files: 
  Unknown files: 
  All changed files: 
  All modified files: 
  Input files: mydir/**
  Matching modified files: 
  Non Matching modified files: .github/workflows/main.yml

Anything else?

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

[BUG] Glob vs regex in readme and execution when using * in with: files:

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug?

The readme currently contains:

      - name: Get specific changed files
        id: changed-files-specific
        uses: tj-actions/[email protected]
        with:
          files: |
            my-file.txt
            test.txt
            new.txt
            test_directory
            *.sh
            .(png|jpeg)$
            .(sql)$
            ^(mynewfile|custom)

These examples are utilizing behavior undefined in the ERE

The asterisk, plus-sign, question-mark, and left-brace shall be special except when used in a bracket expression (see RE Bracket Expression). Any of the following uses produce undefined results:
If these characters appear first in an ERE, or immediately following an unescaped vertical-line, circumflex, dollar-sign, or left-parenthesis

GNU Grep allows them to be a part of EREs, but this can cause issues when it's used by other parts of the entrypoint script.

To Reproduce

Given a directory structure such as

โ”œโ”€โ”€ directory
โ”‚ย ย  โ””โ”€โ”€ child_dir.sh
โ””โ”€โ”€ root_dir.sh

and an action such as

      - name: get changed files
        id: changed_files
        uses: tj-actions/[email protected]
        with:
          files: |
            *.sh

output shows *.sh gets expanded by the bash entrypoint script as a glob:

[...]
Checking for file changes: "root_dir.sh"...
[...]
Matching modified files: 
Non Matching modified files:  root_dir.sh directory/child_dir.sh

as opposed to the expected

[...]
  Checking for file changes: "*.sh"...
[...]
Matching modified files: root_dir.sh directory/child_dir.sh
Non Matching modified files:

What OS are you seeing the problem on?

ubuntu-latest or ubuntu-20.04

Expected behavior?

If *.sh is in the examples, it should work to find any files with .sh in them. If not, it should be removed from the examples along with .

Variables with expected special characters should be quoted to prevent globbing when using them in output.

Relevant log output

No response

Anything else?

For the *.sh example, .*\.sh works as a replacement.

https://www.gnu.org/software/grep/manual/html_node/Basic-vs-Extended.html

Code of Conduct

  • I agree to follow this project's Code of Conduct

[BUG] in entrypoint is referring to gihub.com repository

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug?

This line in entrypoint.sh is adding temporary remote
git remote add temp_changed_files "https://${INPUT_TOKEN}@github.com/${GITHUB_REPOSITORY}"
This is not correct for enterprise github servicer has name like github.enterprise.com and therefore this code does not work and it is trying to access some gihub.com repository which does not exist

To Reproduce

none

What OS are you seeing the problem on?

ubuntu-latest or ubuntu-20.04

Expected behavior?

set correct url as remote

Relevant log output

No response

Anything else?

we are using selfhosted runners

Code of Conduct

  • I agree to follow this project's Code of Conduct

fatal error when using @v4.2

Describe the bug
I get the following:

Run tj-actions/[email protected]
Getting head sha...
fatal: ambiguous argument 'HEAD^1': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
Getting diff...
fatal: ambiguous argument 'HEAD^1': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
Error: Process completed with exit code 128.

To Reproduce
My template:

      - name: Get modified files using defaults
        id: changed-files
        uses: tj-actions/[email protected]

Expected behavior
That the system would get a list of changed files

Additional context
using ubuntu-latest

[BUG] Files input doesn't work when running with `act`

Is there an existing issue for this?

  • I have searched the existing issues

Does this issue exist in the latest version?

  • I'm using the latest release

Describe the bug?

When running this action with act (medium image) and providing a files input, the full list of modified files is returned rather than the a filtered list.

To Reproduce

  1. Add action to repo as configured below
  2. Add multiple changed files in commit, but only 1 with a .yaml extension
  3. Run action locally with act
name: Test

on:
  push:

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v2
        with:
          fetch-depth: 0

      - name: Get changes
        id: changes
        uses: tj-actions/[email protected]
        with:
          files: \.yaml$

      - name: Show changes
        shell: bash
        run: |
          set -euo pipefail

          for file in ${{ steps.changes.outputs.all_modified_files }}
          do
            echo "${file}"
          done

What OS are you seeing the problem on?

ubuntu-latest or ubuntu-20.04

Expected behavior?

The same output should happen with act and on GitHub.

Relevant log output

No response

Anything else?

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

issues with failed getting changed files

hi,
I met the following errors when using git enterprise. btw, I use ssh login the git repo other than username/password. I changed other repo with .git subdirectory, it still complains the same error. I double checked my repo it works fine but still failed to get this github action works

error log:

Run tj-actions/changed-files@v7
with:
token: ***
separator:
/usr/bin/docker run --name fe336efc00c723f4a47d480e9c9a46f254d67_122cbd --label 6fe336 --workdir /github/workspace --rm -e INPUT_TOKEN -e INPUT_SEPARATOR -e INPUT_FILES -e HOME -e GITHUB_JOB -e GITHUB_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_REPOSITORY_OWNER -e GITHUB_RUN_ID -e GITHUB_RUN_NUMBER -e GITHUB_RETENTION_DAYS -e GITHUB_ACTOR -e GITHUB_WORKFLOW -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GITHUB_EVENT_NAME -e GITHUB_SERVER_URL -e GITHUB_API_URL -e GITHUB_GRAPHQL_URL -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e GITHUB_PATH -e GITHUB_ENV -e RUNNER_OS -e RUNNER_TOOL_CACHE -e RUNNER_TEMP -e RUNNER_WORKSPACE -e ACTIONS_RUNTIME_URL -e ACTIONS_RUNTIME_TOKEN -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/daniel/actions-runner/_work/_temp/_github_home":"/github/home" -v "/home/daniel/actions-runner/_work/_temp/_github_workflow":"/github/workflow" -v "/home/daniel/actions-runner/_work/_temp/_runner_file_commands":"/github/file_commands" -v "/home/daniel/actions-runner/_work/temp-repo-4-github-action/temp-repo-4-github-action":"/github/workspace" 6fe336:efc00c723f4a47d480e9c9a46f254d67
fatal: not a git repository (or any parent up to mount point /github)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).

my .git/workflow/ci.yaml

name: CI
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
changedfiles:
runs-on: [ self-hosted ]
name: Test changed-files
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0

  - name: Get changed files
    id: changed-files
    uses: tj-actions/changed-files@v7
  
  - name: List all modified files
    run: |
      for file in "${{ steps.changed-files.outputs.all_modified_files }}"; do
        echo "$file was modified"
      done

[BUG] Changed files not working on self hosted runners

Is there an existing issue for this?

  • I have searched the existing issues

Does this issue exist in the latest version?

  • I'm using the latest release

Describe the bug?

Not working on self hosted github runners.

To Reproduce

  1. Have a self hosted github runner.
  2. Run this action as part of a workflow more than 2 times.

What OS are you seeing the problem on?

ubuntu-latest or ubuntu-20.04

Expected behavior?

Action should work on self hosted github runners.

Relevant log output

error: remote temp_changed_files already exists.


### Anything else?

This is most likely because the script adds a new origin to calculate the changed files.
In the self hosted runner, the state is maintained and the subsequent builds run into the issue of where the required git origin is already added.

I think a check can be added to see if this already exists.

### Code of Conduct

- [X] I agree to follow this project's Code of Conduct

[BUG] Dedupe the output list of changed files

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug?

There's a possibility of returning the same file twice when it matches one or more regex used in the files input.

To Reproduce

  1. Create a .github/workflows/test.yml
  2. Enter the following
  uses: tj-actions/changed-files@v9
  with:
    files: |
		path-to-files
	    .(js|ts|tsx|scss)$
  ...

What OS are you seeing the problem on?

all

Expected behavior?

The list of changed files returned shouldn't be duplicated.

Relevant log output

All changed files: path-to-files/test.js path-to-files/test.js

Anything else?

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

[Feature] Documentation for difference between all_changed_files and all_modified_files

Is your feature request related to a problem? Please describe.

I can't tell the difference between all_changed_files and all_modified_files.

Describe the solution you'd like?

I would love it if the two were clearly distinguished in the documentation.

Describe alternatives you've considered?

No response

Anything else?

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

[Feature] Specify sed delimiter or escaping forward slashes used in separator

Is your feature request related to a problem? Please describe.

When using a separator containing a forward slash, sed interprets it as a delimiter, leading to errors such as

Checking for file changes: ...
sed: -e expression #1, char 9: unknown option to `s'

https://github.com/tj-actions/changed-files/blob/main/entrypoint.sh#L118-L136

Describe the solution you'd like?

Either an option to choose the delimiter with a default to /, e.g. setting SED_DELIMITER=@ would turn the sed commands into sed 's@ *@'"$INPUT_SEPARATOR"'@g' and / would not be interpreted as a delimiter.
or
Escaping forward slashes used in separator.

The latter may reduce the number of initial errors or confusion more than the former.

Describe alternatives you've considered?

Escaping forward slashes works fine for short separators, e.g. \/ but becomes onerous when using unixy paths, web addresses, etc.

Anything else?

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

[BUG] changed-files unable to initialize git repository on custom container image

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug?

when using a custom container image on ubuntu-latest, changed-files is unable to initialize a the git repository

  fatal: not a git repository (or any parent up to mount point /)
  Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
  Error: Process completed with exit code 128.

To Reproduce

consider this action --

  quality-checks:
    runs-on: ubuntu-latest
    container:
      image: 123456789.dkr.ecr.us-west-2.amazonaws.com/my-test-container:latest
      credentials:
        username: AWS
        password: saved-password
    steps:
      - uses: actions/checkout@v2
        with:
          fetch-depth: 2
      - name: Get changed files
        id: changed-files-specific
        uses: tj-actions/[email protected]
        with:
          files: |
            /__w/my-test-container/my-test-container/*.py

during the Initialize containers step i see it create my container with a working directory--

  /usr/bin/docker create --name 123456789amazonawscommytestcontainerklatest_91g223 --label c9e036 --workdir /__w/my-test-container/my-test-container 

then during the actions/checkout it wipes the correct working dir and checks out the code --

Syncing repository: MyRepo/my-test-container
Getting Git version info
Deleting the contents of '/__w/my-test-container/my-test-container'
The repository will be downloaded using the GitHub REST API
To create a local Git repository instead, add Git 2.18 or higher to the PATH
Downloading the archive
Writing archive to disk
Extracting the archive

then changed-files seems to fail when getting the HEAD info --

Run tj-actions/[email protected]
changed-files
  fatal: not a git repository (or any parent up to mount point /)
  Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
  Error: Process completed with exit code 128.

What OS are you seeing the problem on?

ubuntu-latest or ubuntu-20.04

Expected behavior?

is there a way to configure where changed-files looks for the git repo? in this case it should initialize in /__w/my-test-container/my-test-container/

does it need this working-directory option? https://github.community/t/use-working-directory-for-entire-job/16747/2
(seems like this would need some tweaks to the checkout action to allow it to check out to a different directory.

Relevant log output

No response

Anything else?

possible dupe of #100

Code of Conduct

  • I agree to follow this project's Code of Conduct

[Feature] Rename `files` -> `paths` [#tara-label-enhancement] [#tara-label-good first issue]

Is your feature request related to a problem? Please describe.

Given that both files and directories can be added using the files input which seems limited to describing files.

Describe the solution you'd like?

Proposed change here would be renaming files to paths which is more generic and can describe both file based paths and directories.

Describe alternatives you've considered?

No response

Anything else?

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

[Feature] Get Changed files since last successful Action run

Is your feature request related to a problem? Please describe.

Im trying to find changes not since the last commit on main branch, but since the last commit on main branch with a successful action run.

I found this handy action: https://github.com/nrwl/last-successful-commit-action
but I find no way to define which commit to compare to.
I did find the sha config variable, but apparently that is to say "what is the current" commit. Not what is the target commit to compare to.

Describe the solution you'd like?

Perhaps a target_sha setting?

Describe alternatives you've considered?

No response

Anything else?

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

Improve test coverage

  • Setup a test folder
  • Support testing added files
  • Support testing copied files
  • Support testing modified files
  • Support testing deleted files
  • Support testing renamed files
  • Support testing files with their type changed
  • Support testing unmerged files
  • Support testing unknown files

[BUG] any_changed reports true without matching changed files

Describe the bug
When testing for changes in specific file types the any_changed output is true while it should be false.

To Reproduce
Steps to reproduce the behavior:

  1. Add the following to a yml file
- name: Get specific changed files
   id: specific_changed_files
   uses: tj-actions/changed-files@v6
   with:
      files: |
        .(php|css|js|vue)$
- name: Run step if any of the listed files above change
   if: steps.specific_changed_files.outputs.any_changed == 'true'
   run: |
      echo "One or more files listed above has changed."
  1. Commit to GitHub without changing any of the match file types.

Expected behavior
echo "One or more files listed above has changed." should not run since no files are changed as can be seen in the screenshot.

Screenshots
Screenshot 2021-05-16 at 18 43 25

[BUG] Failed to get change files on pull_request merge event

Is there an existing issue for this?

  • I have searched the existing issues

Does this issue exist in the latest version?

  • I'm using the latest release

Describe the bug?

We use changed-files in one of our github workflows. It's basically triggered on pull_request merge. Snippet of code:

on:
  pull_request:
    types: [closed]
    paths:
      - 'abc/def/**'

jobs:
  Publish-Pipelines:
    if: github.event.pull_request.merged == true
......

However, in one of our PR merge event, I found the workflow failed with following info:

changed-files
  Resolving repository path...
  Setting up 'temp_changed_files' remote...
  No 'temp_changed_files' remote found
  Creating 'temp_changed_files' remote...
  Getting HEAD info...
  remote: Enumerating objects: 23, done.        
  remote: Counting objects:   4% (1/23)        
  remote: Counting objects:   8% (2/23)        
  remote: Counting objects:  13% (3/23)        
  remote: Counting objects:  17% (4/23)        
  remote: Counting objects:  21% (5/23)        
  remote: Counting objects:  26% (6/23)        
  remote: Counting objects:  30% (7/23)        
  remote: Counting objects:  34% (8/23)        
  remote: Counting objects:  39% (9/23)        
  remote: Counting objects:  43% (10/23)        
  remote: Counting objects:  47% (11/23)        
  remote: Counting objects:  52% (12/23)        
  remote: Counting objects:  56% (13/23)        
  remote: Counting objects:  60% (14/23)        
  remote: Counting objects:  65% (15/23)        
  remote: Counting objects:  69% (16/23)        
  remote: Counting objects:  73% (17/23)        
  remote: Counting objects:  78% (18/23)        
  remote: Counting objects:  82% (19/23)        
  remote: Counting objects:  86% (20/23)        
  remote: Counting objects:  91% (21/23)        
  remote: Counting objects:  95% (22/23)        
  remote: Counting objects: 100% (23/23)        
  remote: Counting objects: 100% (23/23), done.        
  remote: Compressing objects:  25% (1/4)        
  remote: Compressing objects:  50% (2/4)        
  remote: Compressing objects:  75% (3/4)        
  remote: Compressing objects: 100% (4/4)        
  remote: Compressing objects: 100% (4/4), done.        
  remote: Total 12 (delta 8), reused 9 (delta 6), pack-reused 0        
  From https://github.com/instacart/carrot
   ! [rejected]            master     -> master  (non-fast-forward)
   * [new branch]          master     -> temp_changed_files/master
  Error: Process completed with exit code 1.

I am wondering what may be the issue? The only thing I can think of is that, the PR was uploaded 8 days ago and merged today, which was the long time span. Would that cause any issue?

To Reproduce

See bug description

What OS are you seeing the problem on?

ubuntu-latest or ubuntu-20.04

Expected behavior?

Workflow should go through

Relevant log output

No response

Anything else?

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

[Feature] Ability to run a workflow if and only if certain file/directory changes

Is your feature request related to a problem? Please describe.

Use case:
I want to run a workflow if and only if any file under a certain directory changes.

If any other files have changed I do not want to run the workflow.

In my case, I'm trying to auto-approve a PR using this action https://github.com/marketplace/actions/auto-approve
but only if files under the dev directory have been updated, and nothing else.

Describe the solution you'd like?

Ideally something like this:

    steps:
    - uses: actions/checkout@v2
    - name: Get changed files for dev
      id: changed-files-dev
      uses: tj-actions/[email protected]
      with:
        files: |
          dev
    - uses: hmarr/auto-approve-action@v2
      if: steps.changed-files-dev.outputs.only_changed == 'true'
      with:
        github-token: "${{ secrets.GITHUB_TOKEN }}"

Where only_changed would be true if any file in that directory were present, and ONLY files in that directory were in the diff (i.e no other files)

Describe alternatives you've considered?

I've tried something like this:

    steps:
    - uses: actions/checkout@v2
    - name: Get changed files for dev
      id: changed-files-dev
      uses: tj-actions/[email protected]
      with:
        files: |
          dev
    - name: Get changed files for all
      id: changed-files-rest
      uses: tj-actions/[email protected]
      with:
        files: |
          ^(dev)
    - uses: hmarr/auto-approve-action@v2
      if: steps.changed-files-dev.outputs.any_changed == 'true' && steps.changed-files-rest.outputs.any_changed == 'false'
      with:
        github-token: "${{ secrets.GITHUB_TOKEN }}"

But that doesn't seem to work and feels clunky.

Anything else?

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

[Feature] Add support for checkout path

Is your feature request related to a problem? Please describe.

I am checking out multiple repositories like this:

      - name: Checkout this repo
        uses: actions/checkout@v2
        with:
          path: this
          fetch-depth: 2

      - name: Checkout another repo
        uses: actions/checkout@v2
        with:
          repository: SomeAccount/AnotherRepo
          path: another
          fetch-depth: 2

But this action only works for default checkout path.

Describe the solution you'd like?

Like this:

      - name: Get changed files from this repo
        id: changed-files-this
        uses: tj-actions/[email protected]
        with:
          #  Same path as in the "checkout" action
          path: this

      - name: Get changed files from another repo
        id: changed-files-another
        uses: tj-actions/[email protected]
        with:
          #  Same path as in the "checkout" action
          path: another

Describe alternatives you've considered?

No response

Anything else?

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

[Feature] Get specific changed files reading a file

Is your feature request related to a problem? Please describe.

Hi guys!
I have a Step with a lot of entries in files: input and those entries often change. Since I already have an existing file with all files that could change (one for line), is there the possibility to provide this specific file to read from?

Describe the solution you'd like?

An example of implementation:

source file files-list.txt:

my-file.txt
test.txt
new.txt
test_directory
.(png|jpeg)$   
.(sql)$
^(mynewfile|custom)

Action step:

- name: Get specific changed files from a file
  id: changed-files-specific
  uses: tj-actions/[email protected]
  with:
    read-from-file: files-list.txt

Describe alternatives you've considered?

No response

Anything else?

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

[BUG] When running in a workflow generated by a dependabot BUMP PR, the action fails

Is there an existing issue for this?

  • I have searched the existing issues

Does this issue exist in the latest version?

  • I'm using the latest release

Describe the bug?

When dependabot creates a PR to bump a package, calls to this action results in one of two errors

  Resolving repository path...
  Setting up 'temp_changed_files' remote...
  No 'temp_changed_files' remote found
  Creating 'temp_changed_files' remote...
  error: remote temp_changed_files already exists.
  Error: Process completed with exit code 3.

or

 Resolving repository path...
 Setting up 'temp_changed_files' remote...
 No 'temp_changed_files' remote found
 Creating 'temp_changed_files' remote...
 Getting HEAD info...
 fatal: could not read Password for 'https://***@github.com': No such device or address
 Error: Process completed with exit code 128.

To Reproduce

Simply create a workflow that triggers on Pull Requests and uses tj-actions/[email protected]

If dependabot creates the PR, then the action fails.

What OS are you seeing the problem on?

ubuntu-latest or ubuntu-20.04

Expected behavior?

Should work just the same as if a normal user created a PR

Relevant log output

See above

Anything else?

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

Should the Major Issue Version Point to the Latest Minor?

Is your feature request related to a problem? Please describe.
I am looking for a way to use the latest version of a specific major version in my pipeline. I would like to use the latest v5 version but comparing the latest commit hashes of v5.3 and v5, I see that these currently does not match.

Describe the solution you'd like
It would be helpful if we can specify tj-actions/changed-files@v5 or tj-actions/[email protected] to mean to use latest v5 branch.

Describe alternatives you've considered
I am currently using tj-actions/changed-files@v5 in my action and only hope it gets pointed to the latest release.

Additional context
None

support windows-latest

Is your feature request related to a problem? Please describe.
uh yes, when i use this workflow in windows-latest env, it cause a error:

Run tj-actions/changed-files@v7
  with:
    token: ***
    separator:  
Error: Container action is only supported on Linux

And that is because i should run my C++ workflow in win to use msvc, and i want to use change-file together

Describe the solution you'd like
Add win support

[BUG] <any_changed doesn't capture changes due to renaming files>

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug?

I would expect any_changed to be true when there is a renamed file. It looks like any changed doesn't take renamed files into account.

To Reproduce

Rename a file in the specified directory and then check the any_changed flag.
Screen Shot 2021-07-23 at 4 04 42 PM

For the specific case when I came across this, the file was renamed (moved from a directory outside the one specified into the specified AutomatedTests directory) but also had additional changes. It only showed up in the renamed files list.

What OS are you seeing the problem on?

ubuntu-latest or ubuntu-20.04

Expected behavior?

If there is anything listed for "All changed files" that the any_changed flag would be true.

Relevant log output

Checking for file changes: "AutomatedTests"...
  Added files: 
  Copied files: 
  Deleted files: 
  Modified files: 
  Renamed files: AutomatedTests/DownloadDatabaseTestCase.swift
  Type Changed files: 
  Unmerged files: 
  Unknown files: 
  All changed files: AutomatedTests/DownloadDatabaseTestCase.swift
  All modified files: 
  Input files: AutomatedTests
  Matching modified files:

Anything else?

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

[BUG] pull request with `since_last_remote_commit = true` returns fatal: bad object

Is there an existing issue for this?

  • I have searched the existing issues

Does this issue exist in the latest version?

  • I'm using the latest release

Describe the bug?

The action is not able to locate the last remote commit on the pull-request.

To Reproduce

Here is the action YAML:

    steps:
      - uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579
        with:
          ref: "${{ github.event.pull_request.head.sha }}"
      - id: changed-files
        uses: tj-actions/changed-files@aae164d51be780a235cdeea89752bbacbbfee3c3
        with:
          files: |
            ^${{ env.PROJECT_PATH }}
          sha: "${{ github.event.pull_request.head.sha }}"
          since_last_remote_commit: "true"

When this workflow is executed, it results in several fatal: bad object 9b20d537dc9a0943ad43cd8e6a08c444640a75e3 errors, and all outputs are blank. That commit SHA is correct -- it was the last remote commit on the pull-request branch. It also returns the correct commit SHA if there are multiple commits pushed at the same time.

What OS are you seeing the problem on?

ubuntu-latest or ubuntu-20.04

Expected behavior?

I expect the action to provide a diff of files between the last remote commit on the pull-request (which it correctly figures out) and the HEAD commit of the pull-request (the last commit that was pushed -- which I have confirmed in the output is also correct). Perhaps the base ref needs to be explicitly fetched from the remote in order for it to be found.

Relevant log output

Run tj-actions/changed-files@aae164d51be780a235cdeea89752bbacbbfee3c3
  with:
    files: ^libraries/terraform/name-provider
    since_last_remote_commit: true
    token: ***
    separator:  
    sha: e42496235d245861a95249a5c04c06d3907f19a0
  env:
    PROJECT_NAME: terraform-name-provider
    PROJECT_PATH: libraries/terraform/name-provider
Run bash $GITHUB_ACTION_PATH/sourcefiles.sh
  bash $GITHUB_ACTION_PATH/sourcefiles.sh
  shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
  env:
    PROJECT_NAME: terraform-name-provider
    PROJECT_PATH: libraries/terraform/name-provider
    INPUT_FILES: ^libraries/terraform/name-provider
    INPUT_FILES_FROM_SOURCE_FILE: 
changed-files-from-source-file
  Input Files: ^libraries/terraform/name-provider
  All Unique Input files: ^libraries/terraform/name-provider
Run if [[ -n "" ]]; then
  if [[ -n "" ]]; then
    echo "::set-output name=base_sha::"
  elif [[ "true" == "true" && -z "" ]]; then
    echo "::set-output name=base_sha::9b20d537dc9a0943ad43cd8e6a08c444640a75e3"
  fi
  shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
  env:
    PROJECT_NAME: terraform-name-provider
    PROJECT_PATH: libraries/terraform/name-provider
Run bash $GITHUB_ACTION_PATH/entrypoint.sh
  bash $GITHUB_ACTION_PATH/entrypoint.sh
  shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
  env:
    PROJECT_NAME: terraform-name-provider
    PROJECT_PATH: libraries/terraform/name-provider
    GITHUB_SERVER_URL: https://github.com
    GITHUB_REPOSITORY: [REDACTED]
    GITHUB_BASE_REF: master
    INPUT_SHA: e42496235d245861a95249a5c04c06d3907f19a0
    INPUT_BASE_SHA: 9b20d537dc9a0943ad43cd8e6a08c444640a75e3
    INPUT_TOKEN: ***
    INPUT_FILES: ^libraries/terraform/name-provider
    INPUT_SEPARATOR:  
    INPUT_PATH: 
changed-files
  Resolving repository path...
  Setting up 'temp_changed_files' remote...
  No 'temp_changed_files' remote found
  Creating 'temp_changed_files' remote...
  Getting HEAD info...
  From https://github.com/[REDACTED]
   * [new branch]          master     -> master
   * [new branch]          master     -> temp_changed_files/master
  Retrieving changes between 9b20d537dc9a0943ad43cd8e6a08c444640a75e3 (master) โ†’ e42496235d245861a95249a5c04c06d3907f19a0 ([REDACTED])
  Input files: ^libraries/terraform/name-provider
  Checking for file changes: "^libraries/terraform/name-provider"...
  fatal: bad object 9b20d537dc9a0943ad43cd8e6a08c444640a75e3
  fatal: bad object 9b20d537dc9a0943ad43cd8e6a08c444640a75e3
  fatal: bad object 9b20d537dc9a0943ad43cd8e6a08c444640a75e3
  fatal: bad object 9b20d537dc9a0943ad43cd8e6a08c444640a75e3
  fatal: bad object 9b20d537dc9a0943ad43cd8e6a08c444640a75e3
  fatal: bad object 9b20d537dc9a0943ad43cd8e6a08c444640a75e3
  fatal: bad object 9b20d537dc9a0943ad43cd8e6a08c444640a75e3
  fatal: bad object 9b20d537dc9a0943ad43cd8e6a08c444640a75e3
  fatal: bad object 9b20d537dc9a0943ad43cd8e6a08c444640a75e3
  fatal: bad object 9b20d537dc9a0943ad43cd8e6a08c444640a75e3
  fatal: bad object 9b20d537dc9a0943ad43cd8e6a08c444640a75e3
  Matching modified files: 
  fatal: bad object 9b20d537dc9a0943ad43cd8e6a08c444640a75e3
  Matching deleted files: 
  Added files: 
  Copied files: 
  Deleted files: 
  Modified files: 
  Renamed files: 
  Type Changed files: 
  Unmerged files: 
  Unknown files: 
  All changed files: 
  All modified files:

Anything else?

As an aside, this logging can be misleading:

Retrieving changes between X (master) โ†’ Y (branch)

Since the X commit may not be from master.

Code of Conduct

  • I agree to follow this project's Code of Conduct

[BUG] `all_modified_files` show deleted files

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug?

Hi everyone,
First of all thank you for this action , It is really helpful!
As I understood right documentation all_modified_files - showing only ACMR

Select all modified filesi.e.ย a combination of all added,copied, modified and renamed files (ACMR).

But , when I deleted directory with files it show as all_modified_files. In my opinion It's wrong behaviour.

(Plz correct me if I wrong)

To Reproduce

  1. Created some branch in repo.
  2. Added two directory: first test_pipeline and nested directory new and few .yaml files inside new directory .
  3. Ran workflow and all_modified_files -show me everything correct.
  4. Deleted directory new
  5. Ran workflow again and saw all deleted files.

What OS are you seeing the problem on?

ubuntu-latest or ubuntu-20.04

Expected behavior?

Donโ€™t output deleted files

Relevant log output

Retrieving changes between 1bfe9ff893a8625996ba04b052cdf89e1e683520 (test-gha-custom-label) โ†’ 40ea730b3389a39578a9eeba23c1eda181dfb894 (test-gha-custom-label)
  Checking for file changes: ".(yaml)$"...
  Checking for file changes: "test-pipeline"...
  Added files: 
  Copied files: 
  Deleted files: test-pipeline/new/asaaa.yaml test-pipeline/new/go.yaml
  Modified files: .github/workflows/test-label.yaml
  Renamed files: 
  Type Changed files: 
  Unmerged files: 
  Unknown files: 
  All changed files: .github/workflows/test-label.yaml test-pipeline/new/asaaa.yaml test-pipeline/new/go.yaml
  All modified files: .github/workflows/test-label.yaml test-pipeline/new/asaaa.yaml test-pipeline/new/go.yaml
  Input files: .(yaml)$ test-pipeline
  Matching modified files: .github/workflows/test-label.yaml test-pipeline/new/asaaa.yaml test-pipeline/new/go.yaml

Anything else?

# my config
- name: Get changed files
        id: changed-files
        uses: tj-actions/[email protected]
        with:
          files: |
             .(yaml)$
             test-pipeline

Code of Conduct

  • I agree to follow this project's Code of Conduct

[Feature] Rename `all_changed_files` to `all_changed_and_modified_files`

Is your feature request related to a problem? Please describe.

Thereโ€™s no clear distinction between the term changed and modified

Describe the solution you'd like?

To make a clear distinction between changed files and modified files the current all_changed_files needs to be renamed to all changed and modified files

Describe alternatives you've considered?

No response

Anything else?

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

Rename changed_files -> type_changed_files

Is your feature request related to a problem? Please describe.
Clean up tasks. which should resolve any confusion with changed vs modified.

Describe the solution you'd like
All references to changed_files are modified to type_changed_files.

Request: Option to Output Whole File Path

Is your feature request related to a problem? Please describe.
I want to check if the file that's changed is in a specific directory.

Describe the solution you'd like

with:
  show_file_path: true

Describe alternatives you've considered
I could do git status and check within a run: block, but it seems like it would fit bettere as part of this action

Additional context
Sample output:

{
  added_files: Dockerfile src/components/Modal.jsx
  ...
}

Feature request

Is it possible to add support for push commits?
i think it would be even more useful

Can't get `since_last_remote_commit` to work properly on pull_request event

Is this feature missing in the latest version?

  • I'm using the latest release

Is your feature request related to a problem? Please describe.

If I am not mistaken since_last_remote_commit option compares all changes between the last commit available in remote.
When using the next step:

- name: Check changes
        id: changed-files
        uses: tj-actions/[email protected]
        with:
          # fetch-depth: 0
          since_last_remote_commit: 'true'

I get the following result: README.md iv.yaml package.json
I am changing only the github action file between pushes, how is it possible?. What am I missing?.

Describe the solution you'd like?

Explanation of current behabior

Describe alternatives you've considered?

No response

Anything else?

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

[BUG] Usage of quotes around array items

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug?

Based on the documentation using "${ARRAY}" and looping over the items results in a single item instead of looping over each item in an array.

To Reproduce

ARRAY=(a b c d)

for i in "${ARRAY}"
   echo i

This prints out:

a b c d

as opposed to:

a
b
c
d

What OS are you seeing the problem on?

all

Expected behavior?

a
b
c
d

Relevant log output

No response

Anything else?

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

[Feature] Improve error handling of non local commit reference

Is this feature missing in the latest version?

  • I'm using the latest release

Is your feature request related to a problem? Please describe.

When using this action errors from non existing commits donโ€™t result in a failure.

See: #253

Describe the solution you'd like?

Any commit that doesnโ€™t exist locally warns the users with a possible resolution

Describe alternatives you've considered?

No response

Anything else?

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

[Feature] Add "any_modified", "other_modified_files" and "all_modified" outputs containing created, edit, renamed, or deleted files

Is this feature missing in the latest version?

  • I'm using the latest release

Is your feature request related to a problem? Please describe.

In order to test for changes of any kind (create, edit, rename, delete), a combination of 2 conditions is required, like:

if: ${{ steps.changed-files-specific.outputs.any_changed == 'true' || steps.changed-files-specific.outputs.any_deleted == 'true' }}

This works well, but it's a bit too long and could be simplified into a single expression.

Describe the solution you'd like?

If possible, add 2 new outputs any_touched or all_touched which let the user check for any type of modification to the repository contents. Something like:

if: ${{ steps.changed-files-specific.outputs.any_touched == 'true' }}

Describe alternatives you've considered?

Using two conditions with an OR operator, as described in the beginning.

Anything else?

Gitlab CI's only:changes clause behaves similarly to what I'm requesting.

An example of why these variables might be useful is when running test jobs. If the commit only has changes to the README, test jobs could be skipped since no .py files were touched.

Code of Conduct

  • I agree to follow this project's Code of Conduct

[BUG] not able to find only python files

Is there an existing issue for this?

  • I have searched the existing issues

Does this issue exist in the latest version?

  • I'm using the latest release

Describe the bug?

  • name: Get specific changed files
    id: changed-files
    uses: tj-actions/changed-files@v11
    with:
    files: |
    .py

i want only python files to be captured and using above format which doesnt work and giving below error.

fatal: bad object

To Reproduce

  • name: Get specific changed files
    id: changed-files
    uses: tj-actions/changed-files@v11
    with:
    files: |
    .py

i want only python files to be captured and using above format which doesnt work and giving below error.

fatal: bad object

What OS are you seeing the problem on?

ubuntu-18.04

Expected behavior?

only python files should come in the output

Relevant log output

No response

Anything else?

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

[Feature] Get changed files in all commits in push

Is this feature missing in the latest version?

  • I'm using the latest release

Is your feature request related to a problem? Please describe.

The current action seems to just find changed files in the last commit. If a push includes multiple commits, then changed files in all but the last commit will be ignored.

Describe the solution you'd like?

The ability to list all changed files in all commits in a push that triggers the action.

Describe alternatives you've considered?

No response

Anything else?

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Awaiting Schedule

These updates are awaiting their schedule. Click on a checkbox to get an update now.

  • chore(deps): lock file maintenance

Edited/Blocked

These updates have been manually edited so Renovate will no longer make changes. To discard all commits and start over, click on a checkbox.

Detected dependencies

github-actions
.github/workflows/codacy-analysis.yml
  • actions/checkout v4
  • codacy/codacy-analysis-cli-action v4.4.0
  • github/codeql-action v3
.github/workflows/codeql.yml
  • actions/checkout v4
  • github/codeql-action v3
  • github/codeql-action v3
  • github/codeql-action v3
.github/workflows/greetings.yml
  • actions/first-interaction v1
.github/workflows/issue-comment-job-example.yml
  • actions/checkout v4
  • actions/checkout v4
.github/workflows/manual-triggered-job-example.yml
  • actions/checkout v4
.github/workflows/matrix-example.yml
  • actions/checkout v4
  • actions/checkout v4
.github/workflows/multi-job-example.yml
  • actions/checkout v4
  • actions/checkout v4
.github/workflows/sync-release-version.yml
  • actions/checkout v4
  • tj-actions/release-tagger v4
  • tj-actions/sync-release-version v13
  • tj-actions/sync-release-version v13
  • tj-actions/git-cliff v1
  • peter-evans/create-pull-request v6.0.5
.github/workflows/test.yml
  • actions/checkout v4
  • actions/setup-node v4.0.2
  • tj-actions/eslint-changed-files v25
  • tj-actions/verify-changed-files v19
  • actions/upload-artifact v4
  • codacy/codacy-coverage-reporter-action v1
  • actions/checkout v4
  • actions/download-artifact v4
  • actions/download-artifact v4
  • actions/checkout v4
  • actions/checkout v4
  • actions/download-artifact v4
  • actions/checkout v4
  • actions/download-artifact v4
  • actions/checkout v4
  • actions/download-artifact v4
  • actions/checkout v4
  • actions/download-artifact v4
  • actions/checkout v4
  • actions/download-artifact v4
  • actions/checkout v4
  • actions/download-artifact v4
  • actions/checkout v4
  • actions/download-artifact v4
  • actions/checkout v4
  • actions/download-artifact v4
  • actions/checkout v4
  • actions/download-artifact v4
  • actions/checkout v4
  • actions/download-artifact v4
  • actions/checkout v4
  • actions/download-artifact v4
  • actions/checkout v4
  • actions/download-artifact v4
  • actions/checkout v4
  • actions/download-artifact v4
  • actions/checkout v4
  • actions/download-artifact v4
  • actions/checkout v4
  • actions/checkout v4
  • actions/checkout v4
  • actions/download-artifact v4
  • actions/checkout v4
  • actions/download-artifact v4
  • tj-actions/branch-names v8
  • nrwl/nx-set-shas v4
.github/workflows/update-readme.yml
  • actions/checkout v4
  • tj-actions/auto-doc v3
  • tj-actions/remark v3
  • tj-actions/verify-changed-files v19
  • peter-evans/create-pull-request v6
.github/workflows/workflow-run-example.yml
  • actions/checkout v4
  • actions/checkout v4
npm
package.json
  • @actions/core ^1.10.0
  • @actions/exec ^1.1.1
  • @actions/github ^6.0.0
  • @octokit/rest ^20.0.1
  • @stdlib/utils-convert-path ^0.2.1
  • lodash ^4.17.21
  • micromatch ^4.0.5
  • yaml ^2.3.1
  • @types/jest ^29.5.2
  • @types/lodash ^4.14.195
  • @types/micromatch ^4.0.2
  • @types/node ^20.3.2
  • @types/uuid ^9.0.2
  • @typescript-eslint/eslint-plugin ^7.0.0
  • @typescript-eslint/parser ^7.0.0
  • @vercel/ncc ^0.38.0
  • eslint ^8.43.0
  • eslint-config-prettier ^9.0.0
  • eslint-plugin-github ^4.8.0
  • eslint-plugin-jest ^28.0.0
  • eslint-plugin-prettier ^5.0.0-alpha.2
  • jest ^29.5.0
  • prettier ^3.0.0
  • ts-jest ^29.1.0
  • typescript ^5.1.3

  • Check this box to trigger a request for Renovate to run again on this repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.