diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 000eca17..488135c8 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -138,12 +138,6 @@ jobs:
id: changed-files
continue-on-error: true
uses: ./
-
- - name: Exit with 1 if no error is raised
- if: steps.changed-files.outcome != 'failure' && github.event.action == 'closed'
- run: |
- echo "Expected: (failure) got ${{ steps.changed-files.outcome }}"
- exit 1
- name: Show output
run: |
diff --git a/README.md b/README.md
index 6ab32bfb..3dac661f 100644
--- a/README.md
+++ b/README.md
@@ -115,53 +115,54 @@ Support this project with a :star:
| U | Unmerged |
| X | Unknown |
-| Output | type | example | description |
-|:----------------------------------:|:--------:|:--------------------------------------------------------------:|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|
+| Output | type | example | description |
+|:----------------------------------:|:--------:|:--------------------------------------------------------------:|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|
| any\_changed | `string` | `true` OR `false` | Returns `true` when any
of the filenames provided using
the `files` input has changed. If no `files` have been specified,
an empty string `''` is returned.
i.e. *using a combination of all added,
copied, modified and renamed files (ACMR)* |
-| only\_changed | `string` | `true` OR `false` | Returns `true` when only
files provided using
the `files` input has changed. If no `files` have been specified,
an empty string `''` is returned.
i.e. *using a combination of all added,
copied, modified and renamed files (ACMR)* |
-| other\_changed\_files | `string` | `'new.txt path/to/file.png ...'` | Returns all other changed files
not listed in the files input
i.e. *using a combination of all added,
copied, modified and renamed files (ACMR)* |
+| only\_changed | `string` | `true` OR `false` | Returns `true` when only
files provided using
the `files` input has changed. If no `files` have been specified,
an empty string `''` is returned.
i.e. *using a combination of all added,
copied, modified and renamed files (ACMR)* |
+| other\_changed\_files | `string` | `'new.txt path/to/file.png ...'` | Returns all other changed files
not listed in the files input
i.e. *using a combination of all added,
copied, modified and renamed files (ACMR)* |
| any\_modified | `string` | `true` OR `false` | Returns `true` when any
of the filenames provided using
the `files` input has been modified. If no `files` have been specified,
an empty string `''` is returned.
i.e. *using a combination of all added,
copied, modified, renamed, and deleted files (ACMRD)* |
-| only\_modified | `string` | `true` OR `false` | Returns `true` when only
files provided using
the `files` input has been modified. If no `files` have been specified,
an empty string `''` is returned.(ACMRD) |
-| other\_modified\_files | `string` | `'new.txt path/to/file.png ...'` | Returns all other modified files
not listed in the files input
i.e. *a combination of all added,
copied, modified, and deleted files (ACMRD)* |
+| only\_modified | `string` | `true` OR `false` | Returns `true` when only
files provided using
the `files` input has been modified. If no `files` have been specified,
an empty string `''` is returned.(ACMRD) |
+| other\_modified\_files | `string` | `'new.txt path/to/file.png ...'` | Returns all other modified files
not listed in the files input
i.e. *a combination of all added,
copied, modified, and deleted files (ACMRD)* |
| any\_deleted | `string` | `true` OR `false` | Returns `true` when any
of the filenames provided using
the `files` input has been deleted. If no `files` have been specified,
an empty string `''` is returned. (D) |
| only\_deleted | `string` | `true` OR `false` | Returns `true` when only
files provided using
the `files` input has been deleted. If no `files` have been specified,
an empty string `''` is returned. (D) |
-| other\_deleted\_files | `string` | `'new.txt path/to/file.png ...'` | Returns all other deleted files
not listed in the files input
i.e. *a combination of all deleted files (D)* |
-| all\_changed\_files | `string` | `'new.txt path/to/file.png ...'` | Returns all changed files
i.e. *a combination of all added,
copied, modified and renamed files (ACMR)* |
-| all\_modified\_files | `string` | `'new.txt path/to/file.png ...'` | Returns all changed files
i.e. *a combination of all added,
copied, modified, renamed and deleted files (ACMRD)* |
-| all\_changed\_and\_modified\_files | `string` | `'new.txt path/to/file.png ...'` | Returns all changed
and modified files
i.e. *a combination of (ACMRDTUX)* |
-| all\_old\_new\_renamed\_files | `string` | `'old name.txt,new name.txt old name 2.txt,new name 2.txt...'` | Returns only files that are Renamed and list their old and new names.
NOTE: This requires setting `include_all_old_new_renamed_files` to `true` (R) |
-| added\_files | `string` | `'new.txt path/to/file.png ...'` | Returns only files that are Added (A) |
-| copied\_files | `string` | `'new.txt path/to/file.png ...'` | Returns only files that are Copied (C) |
-| deleted\_files | `string` | `'new.txt path/to/file.png ...'` | Returns only files that are Deleted (D) |
-| modified\_files | `string` | `'new.txt path/to/file.png ...'` | Returns only files that are Modified (M) |
-| renamed\_files | `string` | `'new.txt path/to/file.png ...'` | Returns only files that are Renamed (R) |
-| type\_changed\_files | `string` | `'new.txt path/to/file.png ...'` | Returns only files that have their file type changed (T) |
-| unmerged\_files | `string` | `'new.txt path/to/file.png ...'` | Returns only files that are Unmerged (U) |
-| unknown\_files | `string` | `'new.txt path/to/file.png ...'` | Returns only files that are Unknown (X) |
+| other\_deleted\_files | `string` | `'new.txt path/to/file.png ...'` | Returns all other deleted files
not listed in the files input
i.e. *a combination of all deleted files (D)* |
+| all\_changed\_files | `string` | `'new.txt path/to/file.png ...'` | Returns all changed files
i.e. *a combination of all added,
copied, modified and renamed files (ACMR)* |
+| all\_modified\_files | `string` | `'new.txt path/to/file.png ...'` | Returns all changed files
i.e. *a combination of all added,
copied, modified, renamed and deleted files (ACMRD)* |
+| all\_changed\_and\_modified\_files | `string` | `'new.txt path/to/file.png ...'` | Returns all changed
and modified files
i.e. *a combination of (ACMRDTUX)* |
+| all\_old\_new\_renamed\_files | `string` | `'old name.txt,new name.txt old name 2.txt,new name 2.txt...'` | Returns only files that are Renamed and list their old and new names.
NOTE: This requires setting `include_all_old_new_renamed_files` to `true` (R) |
+| added\_files | `string` | `'new.txt path/to/file.png ...'` | Returns only files that are Added (A) |
+| copied\_files | `string` | `'new.txt path/to/file.png ...'` | Returns only files that are Copied (C) |
+| deleted\_files | `string` | `'new.txt path/to/file.png ...'` | Returns only files that are Deleted (D) |
+| modified\_files | `string` | `'new.txt path/to/file.png ...'` | Returns only files that are Modified (M) |
+| renamed\_files | `string` | `'new.txt path/to/file.png ...'` | Returns only files that are Renamed (R) |
+| type\_changed\_files | `string` | `'new.txt path/to/file.png ...'` | Returns only files that have their file type changed (T) |
+| unmerged\_files | `string` | `'new.txt path/to/file.png ...'` | Returns only files that are Unmerged (U) |
+| unknown\_files | `string` | `'new.txt path/to/file.png ...'` | Returns only files that are Unknown (X) |
## Inputs
-| Input | type | required | default | description |
-|:--------------------------------------:|:----------------------:|:--------:|:---------------------:|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|
-| separator | `string` | `false` | `' '` | Split character for output strings |
-| include\_all\_old\_new\_renamed\_files | `boolean` | `false` | `false` | Include `all_old_new_renamed_files` output. Note this can generate a large output See: [#501](https://github.com/tj-actions/changed-files/issues/501). |
-| old\_new\_separator | `string` | `false` | `','` | Split character for old and new filename pairs |
-| old\_new\_files\_separator | `string` | `false` | `' '` | Split character for multiple old and new filename pairs |
-| files | `string` OR `string[]` | `false` | | Check for changes
using only these
list of file(s)
(Defaults to the
entire repo)
**NOTE:** Multiline file/directory patterns
should not include qoutes.
|
-| files\_separator | `string` | `false` | `'\n'` | Separator used to split the
`files` input |
-| files\_from\_source\_file | `string` | `false` | | Source file(s)
used to populate
the `files` input |
-| files\_ignore | `string` | `false` | | Ignore changes to these file(s)
**NOTE:** Multiline file/directory patterns
should not include qoutes.
|
-| files\_ignore\_separator | `string` | `false` | `'\n'` | Separator used to split the
`files-ignore` input |
-| files\_ignore\_from\_source\_file | `string` | `false` | | Source file(s)
used to populate
the `files_ignore` input |
-| sha | `string` | `true` | `${{ github.sha }}` | Specify a different
commit SHA
used for
comparing changes |
-| base\_sha | `string` | `false` | | Specify a different
base commit SHA
used for
comparing changes |
-| path | `string` | `false` | `'.'` | Relative path under
`GITHUB_WORKSPACE`
to the repository |
-| quotepath | `boolean` | `false` | `true` | Output filenames completely verbatim by setting this to `false` |
-| diff\_relative | `boolean` | `false` | | Exclude changes outside the current directory and show pathnames relative to it. **NOTE:** This requires you to specify the top level directory via the `path` input. |
-| dir\_names | `boolean` | `false` | `false` | Output unique changed directories instead of filenames.
**NOTE:** This returns `.` for
changed files located in the root of the project. |
-| json | `boolean` | `false` | `false` | Output changed files in JSON format which can be used for [matrix jobs](https://github.com/tj-actions/changed-files/blob/main/.github/workflows/manual-matrix-test.yml). |
-| since | `string` | `false` | | Get changed files for commits whose timestamp is older than the given time. |
-| until | `string` | `false` | | Get changed files for commits whose timestamp is earlier than the given time. |
+| Input | type | required | default | description |
+|:--------------------------------------:|:----------------------:|:--------:|:-------------------:|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|
+| separator | `string` | `false` | `' '` | Split character for output strings |
+| include\_all\_old\_new\_renamed\_files | `boolean` | `false` | `false` | Include `all_old_new_renamed_files` output. Note this can generate a large output See: [#501](https://github.com/tj-actions/changed-files/issues/501). |
+| old\_new\_separator | `string` | `false` | `','` | Split character for old and new filename pairs |
+| old\_new\_files\_separator | `string` | `false` | `' '` | Split character for multiple old and new filename pairs |
+| files | `string` OR `string[]` | `false` | | Check for changes
using only these
list of file(s)
(Defaults to the
entire repo)
**NOTE:** Multiline file/directory patterns
should not include qoutes.
|
+| files\_separator | `string` | `false` | `'\n'` | Separator used to split the
`files` input |
+| files\_from\_source\_file | `string` | `false` | | Source file(s)
used to populate
the `files` input |
+| files\_ignore | `string` | `false` | | Ignore changes to these file(s)
**NOTE:** Multiline file/directory patterns
should not include qoutes.
|
+| files\_ignore\_separator | `string` | `false` | `'\n'` | Separator used to split the
`files-ignore` input |
+| files\_ignore\_from\_source\_file | `string` | `false` | | Source file(s)
used to populate
the `files_ignore` input |
+| sha | `string` | `true` | `${{ github.sha }}` | Specify a different
commit SHA
used for
comparing changes |
+| base\_sha | `string` | `false` | | Specify a different
base commit SHA
used for
comparing changes |
+| path | `string` | `false` | `'.'` | Relative path under
`GITHUB_WORKSPACE`
to the repository |
+| quotepath | `boolean` | `false` | `true` | Output filenames completely verbatim by setting this to `false` |
+| diff\_relative | `boolean` | `false` | | Exclude changes outside the current directory and show pathnames relative to it. **NOTE:** This requires you to specify the top level directory via the `path` input. |
+| dir\_names | `boolean` | `false` | `false` | Output unique changed directories instead of filenames.
**NOTE:** This returns `.` for
changed files located in the root of the project. |
+| json | `boolean` | `false` | `false` | Output changed files in JSON format which can be used for [matrix jobs](https://github.com/tj-actions/changed-files/blob/main/.github/workflows/manual-matrix-test.yml). |
+| since | `string` | `false` | | Get changed files for commits whose timestamp is older than the given time. |
+| until | `string` | `false` | | Get changed files for commits whose timestamp is earlier than the given time. |
+| target\_branch\_fetch\_depth | `string` | `false` | `20` | Limit fetching commits from the target branch to a specified number. **NOTE**: This can be adjusted to resolve errors with insufficient history. See: [#668](https://github.com/tj-actions/changed-files/issues/668). |
## Examples
@@ -291,11 +292,11 @@ Support this project with a :star:
uses: tj-actions/changed-files@v32
with:
quotepath: "false"
-
+
# Run changed-files action using the last successful commit as the base_sha
# NOTE: 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.
-
+
# Push event based workflows
- name: Get branch name
id: branch-name
diff --git a/action.yml b/action.yml
index dc75e675..0501b614 100644
--- a/action.yml
+++ b/action.yml
@@ -77,6 +77,10 @@ inputs:
description: "Output changed files in JSON format which can be used for matrix jobs"
required: false
default: "false"
+ target_branch_fetch_depth:
+ description: "Limit fetching commits from the target branch to a specified number. **NOTE**: This can be adjusted to resolve errors with insufficient history. See: [#668](https://github.com/tj-actions/changed-files/issues/668)."
+ required: false
+ default: "20"
outputs:
added_files:
@@ -184,14 +188,15 @@ runs:
GITHUB_BASE_REF: ${{ github.base_ref }}
GITHUB_HEAD_REF: ${{ github.head_ref }}
GITHUB_WORKSPACE: ${{ github.workspace }}
- GITHUB_PULL_REQUEST_BASE_SHA: ${{ github.event.pull_request.base.sha }}
+ GITHUB_EVENT_PULL_REQUEST_BASE_SHA: ${{ github.event.pull_request.base.sha }}
GITHUB_EVENT_BEFORE: ${{ github.event.before }}
- GITHUB_EVENT_FORCED : ${{ github.event.forced }}
+ GITHUB_EVENT_FORCED: ${{ github.event.forced }}
# INPUT_ is not available in Composite run steps
# https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#example-specifying-inputs
INPUT_SHA: ${{ steps.sha.outputs.sha }}
INPUT_BASE_SHA: ${{ steps.base-sha.outputs.base_sha }}
INPUT_PATH: ${{ inputs.path }}
+ INPUT_TARGET_BRANCH_FETCH_DEPTH: ${{ inputs.target_branch_fetch_depth }}
- name: Glob match
uses: tj-actions/glob@v15
id: glob
diff --git a/diff-sha.sh b/diff-sha.sh
index 7676fbfa..41aba49c 100644
--- a/diff-sha.sh
+++ b/diff-sha.sh
@@ -62,7 +62,7 @@ if [[ -z $GITHUB_BASE_REF ]]; then
CURRENT_BRANCH=$TARGET_BRANCH && exit_status=$? || exit_status=$?
if [[ -z $INPUT_BASE_SHA ]]; then
- git fetch --no-tags -u --progress origin --depth=2 "${TARGET_BRANCH}":"${TARGET_BRANCH}" && exit_status=$? || exit_status=$?
+ git fetch --no-tags -u --progress origin --depth="$INPUT_TARGET_BRANCH_FETCH_DEPTH" "${TARGET_BRANCH}":"${TARGET_BRANCH}" && exit_status=$? || exit_status=$?
PREVIOUS_SHA=""
if [[ "$GITHUB_EVENT_FORCED" == "false" ]]; then
@@ -103,20 +103,19 @@ else
TARGET_BRANCH=$GITHUB_BASE_REF
CURRENT_BRANCH=$GITHUB_HEAD_REF
- echo "::debug::GITHUB_BASE_REF: $TARGET_BRANCH..."
+ git fetch --no-tags -u --progress origin --depth="$INPUT_TARGET_BRANCH_FETCH_DEPTH" "${TARGET_BRANCH}":"${TARGET_BRANCH}" &&
+ exit_status=$? || exit_status=$?
if [[ -z $INPUT_BASE_SHA ]]; then
- git fetch --no-tags -u --progress origin --depth=1 "${TARGET_BRANCH}":"${TARGET_BRANCH}" && exit_status=$? || exit_status=$?
- PREVIOUS_SHA=$GITHUB_PULL_REQUEST_BASE_SHA && exit_status=$? || exit_status=$?
+ PREVIOUS_SHA=$GITHUB_EVENT_PULL_REQUEST_BASE_SHA && exit_status=$? || exit_status=$?
echo "::debug::Previous SHA: $PREVIOUS_SHA"
else
- git fetch --no-tags -u --progress origin --depth=1 "$(git rev-parse --verify "$INPUT_BASE_SHA")" && exit_status=$? || exit_status=$?
- PREVIOUS_SHA=$INPUT_BASE_SHA
- TARGET_BRANCH=$(git name-rev --name-only "$PREVIOUS_SHA" 2>&1) && exit_status=$? || exit_status=$?
- echo "::debug::Previous SHA: $PREVIOUS_SHA"
- echo "::debug::Target branch: $TARGET_BRANCH"
+ PREVIOUS_SHA=$INPUT_BASE_SHA && exit_status=$? || exit_status=$?
fi
+ echo "::debug::Target branch: $TARGET_BRANCH"
+ echo "::debug::Current branch: $CURRENT_BRANCH"
+
echo "::debug::Verifying the previous commit SHA: $PREVIOUS_SHA"
git rev-parse --quiet --verify "$PREVIOUS_SHA^{commit}" 1>/dev/null 2>&1 && exit_status=$? || exit_status=$?