mirror of
https://github.com/tj-actions/changed-files
synced 2025-01-30 19:30:19 +00:00
Merge branch 'main' into set-output-github-output
This commit is contained in:
commit
be3cb7b5aa
4 changed files with 58 additions and 59 deletions
6
.github/workflows/test.yml
vendored
6
.github/workflows/test.yml
vendored
|
@ -139,12 +139,6 @@ jobs:
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
uses: ./
|
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
|
- name: Show output
|
||||||
run: |
|
run: |
|
||||||
echo '${{ toJSON(steps.changed-files.outputs) }}'
|
echo '${{ toJSON(steps.changed-files.outputs) }}'
|
||||||
|
|
|
@ -116,7 +116,7 @@ Support this project with a :star:
|
||||||
| X | Unknown |
|
| X | Unknown |
|
||||||
|
|
||||||
| Output | type | example | description |
|
| Output | type | example | description |
|
||||||
|:----------------------------------:|:--------:|:--------------------------------------------------------------:|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|
|
|:----------------------------------:|:--------:|:--------------------------------------------------------------:|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|
|
||||||
| any\_changed | `string` | `true` OR `false` | Returns `true` when any <br /> of the filenames provided using <br /> the `files` input has changed. If no `files` have been specified,<br> an empty string `''` is returned. <br /> i.e. *using a combination of all added, <br />copied, modified and renamed files (ACMR)* |
|
| any\_changed | `string` | `true` OR `false` | Returns `true` when any <br /> of the filenames provided using <br /> the `files` input has changed. If no `files` have been specified,<br> an empty string `''` is returned. <br /> i.e. *using a combination of all added, <br />copied, modified and renamed files (ACMR)* |
|
||||||
| only\_changed | `string` | `true` OR `false` | Returns `true` when only <br /> files provided using <br /> the `files` input has changed. If no `files` have been specified,<br> an empty string `''` is returned. <br /> i.e. *using a combination of all added, <br />copied, modified and renamed files (ACMR)* |
|
| only\_changed | `string` | `true` OR `false` | Returns `true` when only <br /> files provided using <br /> the `files` input has changed. If no `files` have been specified,<br> an empty string `''` is returned. <br /> i.e. *using a combination of all added, <br />copied, modified and renamed files (ACMR)* |
|
||||||
| other\_changed\_files | `string` | `'new.txt path/to/file.png ...'` | Returns all other changed files <br/> not listed in the files input <br /> i.e. *using a combination of all added, <br />copied, modified and renamed files (ACMR)* |
|
| other\_changed\_files | `string` | `'new.txt path/to/file.png ...'` | Returns all other changed files <br/> not listed in the files input <br /> i.e. *using a combination of all added, <br />copied, modified and renamed files (ACMR)* |
|
||||||
|
@ -142,7 +142,7 @@ Support this project with a :star:
|
||||||
## Inputs
|
## Inputs
|
||||||
|
|
||||||
| Input | type | required | default | description |
|
| Input | type | required | default | description |
|
||||||
|:--------------------------------------:|:----------------------:|:--------:|:---------------------:|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|
|
|:--------------------------------------:|:----------------------:|:--------:|:-------------------:|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|
|
||||||
| separator | `string` | `false` | `' '` | Split character for output strings |
|
| 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). |
|
| 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\_separator | `string` | `false` | `','` | Split character for old and new filename pairs |
|
||||||
|
@ -162,6 +162,7 @@ Support this project with a :star:
|
||||||
| 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). |
|
| 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. |
|
| 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. |
|
| 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
|
## Examples
|
||||||
|
|
||||||
|
|
|
@ -77,6 +77,10 @@ inputs:
|
||||||
description: "Output changed files in JSON format which can be used for matrix jobs"
|
description: "Output changed files in JSON format which can be used for matrix jobs"
|
||||||
required: false
|
required: false
|
||||||
default: "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:
|
outputs:
|
||||||
added_files:
|
added_files:
|
||||||
|
@ -184,7 +188,7 @@ runs:
|
||||||
GITHUB_BASE_REF: ${{ github.base_ref }}
|
GITHUB_BASE_REF: ${{ github.base_ref }}
|
||||||
GITHUB_HEAD_REF: ${{ github.head_ref }}
|
GITHUB_HEAD_REF: ${{ github.head_ref }}
|
||||||
GITHUB_WORKSPACE: ${{ github.workspace }}
|
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_BEFORE: ${{ github.event.before }}
|
||||||
GITHUB_EVENT_FORCED: ${{ github.event.forced }}
|
GITHUB_EVENT_FORCED: ${{ github.event.forced }}
|
||||||
# INPUT_<VARIABLE_NAME> is not available in Composite run steps
|
# INPUT_<VARIABLE_NAME> is not available in Composite run steps
|
||||||
|
@ -192,6 +196,7 @@ runs:
|
||||||
INPUT_SHA: ${{ steps.sha.outputs.sha }}
|
INPUT_SHA: ${{ steps.sha.outputs.sha }}
|
||||||
INPUT_BASE_SHA: ${{ steps.base-sha.outputs.base_sha }}
|
INPUT_BASE_SHA: ${{ steps.base-sha.outputs.base_sha }}
|
||||||
INPUT_PATH: ${{ inputs.path }}
|
INPUT_PATH: ${{ inputs.path }}
|
||||||
|
INPUT_TARGET_BRANCH_FETCH_DEPTH: ${{ inputs.target_branch_fetch_depth }}
|
||||||
- name: Glob match
|
- name: Glob match
|
||||||
uses: tj-actions/glob@v15
|
uses: tj-actions/glob@v15
|
||||||
id: glob
|
id: glob
|
||||||
|
|
17
diff-sha.sh
17
diff-sha.sh
|
@ -62,7 +62,7 @@ if [[ -z $GITHUB_BASE_REF ]]; then
|
||||||
CURRENT_BRANCH=$TARGET_BRANCH && exit_status=$? || exit_status=$?
|
CURRENT_BRANCH=$TARGET_BRANCH && exit_status=$? || exit_status=$?
|
||||||
|
|
||||||
if [[ -z $INPUT_BASE_SHA ]]; then
|
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=""
|
PREVIOUS_SHA=""
|
||||||
|
|
||||||
if [[ "$GITHUB_EVENT_FORCED" == "false" ]]; then
|
if [[ "$GITHUB_EVENT_FORCED" == "false" ]]; then
|
||||||
|
@ -103,20 +103,19 @@ else
|
||||||
TARGET_BRANCH=$GITHUB_BASE_REF
|
TARGET_BRANCH=$GITHUB_BASE_REF
|
||||||
CURRENT_BRANCH=$GITHUB_HEAD_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
|
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_EVENT_PULL_REQUEST_BASE_SHA && exit_status=$? || exit_status=$?
|
||||||
PREVIOUS_SHA=$GITHUB_PULL_REQUEST_BASE_SHA && exit_status=$? || exit_status=$?
|
|
||||||
echo "::debug::Previous SHA: $PREVIOUS_SHA"
|
echo "::debug::Previous SHA: $PREVIOUS_SHA"
|
||||||
else
|
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 && 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"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo "::debug::Target branch: $TARGET_BRANCH"
|
||||||
|
echo "::debug::Current branch: $CURRENT_BRANCH"
|
||||||
|
|
||||||
echo "::debug::Verifying the previous commit SHA: $PREVIOUS_SHA"
|
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=$?
|
git rev-parse --quiet --verify "$PREVIOUS_SHA^{commit}" 1>/dev/null 2>&1 && exit_status=$? || exit_status=$?
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue