Compare commits

...

17 Commits

Author SHA1 Message Date
Tonye Jack
81ad4b8744 Update entrypoint.sh 2021-09-05 14:21:28 -04:00
Tonye Jack
cfcb385d2b Upgraded to v1.1.1 (#189)
Co-authored-by: jackton1 <jackton1@users.noreply.github.com>
2021-09-05 09:27:41 -04:00
Tonye Jack
5e2a2f1923 Added support for detecting deleted files. (#188) 2021-09-05 08:22:47 -04:00
Tonye Jack
81037a4f7b Update README.md 2021-09-04 11:27:10 -04:00
Tonye Jack
3eeb3186dd Update README.md 2021-09-04 11:26:13 -04:00
Tonye Jack
6f8181a0ea Update README.md 2021-09-04 11:25:23 -04:00
Tonye Jack
368be5bbf0 Rename all_changed_files to all_changed_and_modified_files. (#187) 2021-09-04 09:42:11 -04:00
Tonye Jack
9cc7563ef7 Update other_changed_files output to also use the separator (#186) 2021-09-04 09:31:19 -04:00
Tonye Jack
847613ee23 Upgraded to v1.1.0 (#185)
Co-authored-by: jackton1 <jackton1@users.noreply.github.com>
2021-09-04 09:14:09 -04:00
Tonye Jack
1af9ab3830 Update handling separator. (#181) 2021-09-04 09:08:20 -04:00
Renovate Bot
4c0811d6d3 Update pascalgn/automerge-action action to v0.14.3 2021-09-03 17:06:45 -04:00
Tonye Jack
bfe33aff05 Upgraded to v1.0.3 (#183)
Co-authored-by: jackton1 <jackton1@users.noreply.github.com>
2021-09-03 10:08:15 -04:00
Tonye Jack
55a857d66a Update removing trailing separator (#182)
* Update removing trailing separator

* Update test new.txt
2021-09-03 03:38:10 -04:00
Tonye Jack
684c3a8487 Update README.md 2021-08-29 12:35:45 -04:00
Tonye Jack
9d6b2c32e8 Update README.md 2021-08-29 12:26:16 -04:00
Tonye Jack
e6c1b2487a Update README.md (#178) 2021-08-29 11:28:33 -04:00
Tonye Jack
506cc732d4 Upgraded from v1.0.1 -> v1.0.2 (#176)
Co-authored-by: jackton1 <jackton1@users.noreply.github.com>
2021-08-28 05:40:10 -04:00
9 changed files with 367 additions and 125 deletions

View File

@@ -17,7 +17,7 @@ jobs:
github.actor == 'renovate'
steps:
- name: automerge
uses: pascalgn/automerge-action@v0.14.2
uses: pascalgn/automerge-action@v0.14.3
env:
GITHUB_TOKEN: ${{ secrets.PAT_TOKEN || github.token }}
MERGE_METHOD: "rebase"

View File

@@ -40,13 +40,13 @@ jobs:
path: dir1
- name: Show output
run: |
echo "${{ toJSON(steps.changed-files-dir1.outputs) }}"
echo '${{ toJSON(steps.changed-files-dir1.outputs) }}'
shell:
bash
- name: List all modified files
run: |
for file in "${{ steps.changed-files-dir1.outputs.modified_files }}"; do
echo $file
echo "$file"
done
shell:
bash
@@ -62,13 +62,13 @@ jobs:
path: dir2
- name: Show output
run: |
echo "${{ toJSON(steps.changed-files-dir2.outputs) }}"
echo '${{ toJSON(steps.changed-files-dir2.outputs) }}'
shell:
bash
- name: List all modified files
run: |
for file in "${{ steps.changed-files-dir2.outputs.modified_files }}"; do
echo $file
echo "$file"
done
shell:
bash
@@ -114,7 +114,7 @@ jobs:
uses: ./
- name: Show output
run: |
echo "${{ toJSON(steps.changed-files.outputs) }}"
echo '${{ toJSON(steps.changed-files.outputs) }}'
shell:
bash
- name: List all modified files
@@ -130,6 +130,26 @@ jobs:
echo "Your README.md has been modified ${{ steps.changed-files.outputs.modified_files }}."
shell:
bash
- name: Run changed-files with forward slash separator
id: changed-files-forward-slash
uses: ./
with:
separator: "/"
- name: Show output
run: |
echo '${{ toJSON(steps.changed-files-forward-slash.outputs) }}'
shell:
bash
- name: Run changed-files with pipe separator
id: changed-files-pipe
uses: ./
with:
separator: "|"
- name: Show output
run: |
echo '${{ toJSON(steps.changed-files-pipe.outputs) }}'
shell:
bash
- name: Run changed-files with comma separator
id: changed-files-comma
uses: ./
@@ -137,7 +157,7 @@ jobs:
separator: ","
- name: Show output
run: |
echo "${{ toJSON(steps.changed-files-comma.outputs) }}"
echo '${{ toJSON(steps.changed-files-comma.outputs) }}'
shell:
bash
- name: Run changed-files with specific files
@@ -147,7 +167,12 @@ jobs:
files: |
.github/workflows/test.yml
action.yml
- name: Verify any_changed files
- name: Show output
run: |
echo '${{ toJSON(steps.changed-files-specific.outputs) }}'
shell:
bash
- name: Verify any_changed for specific files
if: "!contains(steps.changed-files-specific.outputs.all_modified_files, 'action.yml') && !contains(steps.changed-files-specific.outputs.all_modified_files, '.github/workflows/test.yml')"
run: |
if [[ "${{ steps.changed-files-specific.outputs.any_changed }}" != "false" ]]; then
@@ -156,9 +181,13 @@ jobs:
fi
shell:
bash
- name: Show output
- name: Verify any_deleted for specific files
if: "!contains(steps.changed-files-specific.outputs.deleted_files, 'action.yml') && !contains(steps.changed-files-specific.outputs.deleted_files, '.github/workflows/test.yml')"
run: |
echo "${{ toJSON(steps.changed-files-specific.outputs) }}"
if [[ "${{ steps.changed-files-specific.outputs.any_deleted }}" != "false" ]]; then
echo "Invalid output: Expected (false) got (${{ steps.changed-files-specific.outputs.any_deleted }})"
exit 1
fi
shell:
bash
- name: Run changed-files with specific files comma check duplicates
@@ -168,14 +197,14 @@ jobs:
files: |
entrypoint.sh
*.sh
- name: Verify all_changed_files files has no duplicates
- name: Verify all_changed_and_modified_files files has no duplicates
if: contains(steps.changed-files-specific-duplicate-output.outputs.all_modified_files, 'entrypoint.sh')
run: |
ALL_CHANGED_FILES=(${{ steps.changed-files-specific-duplicate-output.outputs.all_modified_files }})
UNIQUE_ALL_CHANGED_FILES=$(echo "$ALL_CHANGED_FILES" | tr ' ' '\n' | sort -u | xargs)
ALL_CHANGED_AND_MODIFIED_FILES=(${{ steps.changed-files-specific-duplicate-output.outputs.all_modified_files }})
UNIQUE_ALL_CHANGED_AND_MODIFIED_FILES=$(echo "$ALL_CHANGED_AND_MODIFIED_FILES" | tr ' ' '\n' | sort -u | xargs)
if [[ "$ALL_CHANGED_FILES[@]" != "$UNIQUE_ALL_CHANGED_FILES[@]" ]]; then
echo "Duplicate output: Expected "$UNIQUE_ALL_CHANGED_FILES" got $ALL_CHANGED_FILES"
if [[ "$ALL_CHANGED_AND_MODIFIED_FILES[@]" != "$UNIQUE_ALL_CHANGED_AND_MODIFIED_FILES[@]" ]]; then
echo "Duplicate output: Expected "$UNIQUE_ALL_CHANGED_AND_MODIFIED_FILES" got $ALL_CHANGED_AND_MODIFIED_FILES"
exit 1
fi
shell:
@@ -188,11 +217,87 @@ jobs:
.github/workflows/test.yml
action.yml
separator: ","
- name: Show output
run: |
echo '${{ toJSON(steps.changed-files-specific-comma.outputs) }}'
shell:
bash
- name: Verify any_changed files comma separator
if: "!contains(steps.changed-files-specific-comma.outputs.all_modified_files, 'action.yml') && !contains(steps.changed-files-specific-comma.outputs.all_modified_files, '.github/workflows/test.yml')"
run: |
if [[ "${{ steps.changed-files-specific-comma.outputs.any_changed }}" != "false" ]]; then
echo "Invalid output: Expected (false) got (${{ steps.changed-files-specific-comma.outputs.any_changed }})"
exit 1
fi
shell:
bash
- name: Verify any_deleted files comma separator
if: "!contains(steps.changed-files-specific-comma.outputs.deleted_files, 'action.yml') && !contains(steps.changed-files-specific-comma.outputs.deleted_files, '.github/workflows/test.yml')"
run: |
if [[ "${{ steps.changed-files-specific-comma.outputs.any_deleted }}" != "false" ]]; then
echo "Invalid output: Expected (false) got (${{ steps.changed-files-specific-comma.outputs.any_deleted }})"
exit 1
fi
shell:
bash
- name: Run changed-files with specific files pipe separator
id: changed-files-specific-pipe
uses: ./
with:
files: |
.github/workflows/test.yml
action.yml
separator: "|"
- name: Show output
run: |
echo '${{ toJSON(steps.changed-files-specific-pipe.outputs) }}'
shell:
bash
- name: Verify any_changed files comma separator
if: "!contains(steps.changed-files-specific-pipe.outputs.all_modified_files, 'action.yml') && !contains(steps.changed-files-specific-pipe.outputs.all_modified_files, '.github/workflows/test.yml')"
run: |
if [[ "${{ steps.changed-files-specific-pipe.outputs.any_changed }}" != "false" ]]; then
echo "Invalid output: Expected (false) got (${{ steps.changed-files-specific-pipe.outputs.any_changed }})"
exit 1
fi
shell:
bash
- name: Verify any_deleted files comma separator
if: "!contains(steps.changed-files-specific-pipe.outputs.deleted_files, 'action.yml') && !contains(steps.changed-files-specific-pipe.outputs.deleted_files, '.github/workflows/test.yml')"
run: |
if [[ "${{ steps.changed-files-specific-pipe.outputs.any_deleted }}" != "false" ]]; then
echo "Invalid output: Expected (false) got (${{ steps.changed-files-specific-pipe.outputs.any_deleted }})"
exit 1
fi
shell:
bash
- name: Run changed-files with specific files forward slash separator
id: changed-files-specific-forward-slash
uses: ./
with:
files: |
.github/workflows/test.yml
action.yml
separator: "/"
- name: Show output
run: |
echo '${{ toJSON(steps.changed-files-specific-forward-slash.outputs) }}'
shell:
bash
- name: Verify any_changed files comma separator
if: "!contains(steps.changed-files-specific-forward-slash.outputs.all_modified_files, 'action.yml') && !contains(steps.changed-files-specific-forward-slash.outputs.all_modified_files, '.github/workflows/test.yml')"
run: |
if [[ "${{ steps.changed-files-specific.outputs.any_changed }}" != "false" ]]; then
echo "Invalid output: Expected (false) got (${{ steps.changed-files-specific.outputs.any_changed }})"
echo "Invalid output: Expected (false) got (${{ steps.changed-files-specific-forward-slash.outputs.any_changed }})"
exit 1
fi
shell:
bash
- name: Verify any_deleted files comma separator
if: "!contains(steps.changed-files-specific-forward-slash.outputs.deleted_files, 'action.yml') && !contains(steps.changed-files-specific-forward-slash.outputs.deleted_files, '.github/workflows/test.yml')"
run: |
if [[ "${{ steps.changed-files-specific.outputs.any_deleted }}" != "false" ]]; then
echo "Invalid output: Expected (false) got (${{ steps.changed-files-specific-forward-slash.outputs.any_deleted }})"
exit 1
fi
shell:
@@ -206,18 +311,27 @@ jobs:
test/changed-files-list.txt
files: |
.github/workflows/rebase.yml
- name: Verify any_changed files
if: "!contains(steps.changed-files-specific.outputs.all_modified_files, 'action.yml') && !contains(steps.changed-files-specific.outputs.all_modified_files, '.github/workflows/test.yml')"
- name: Verify any_changed from source files
if: "!contains(steps.changed-files-specific-source-file.outputs.all_modified_files, 'action.yml') && !contains(steps.changed-files-specific-source-file.outputs.all_modified_files, '.github/workflows/test.yml')"
run: |
if [[ "${{ steps.changed-files-specific.outputs.any_changed }}" != "false" ]]; then
echo "Invalid output: Expected (false) got (${{ steps.changed-files-specific.outputs.any_changed }})"
if [[ "${{ steps.changed-files-specific-source-file.outputs.any_changed }}" != "false" ]]; then
echo "Invalid output: Expected (false) got (${{ steps.changed-files-specific-source-file.outputs.any_changed }})"
exit 1
fi
shell:
bash
- name: Verify any_deleted from source files
if: "!contains(steps.changed-files-specific-source-file.outputs.deleted_files, 'action.yml') && !contains(steps.changed-files-specific-source-file.outputs.deleted_files, '.github/workflows/test.yml')"
run: |
if [[ "${{ steps.changed-files-specific-source-file.outputs.any_deleted }}" != "false" ]]; then
echo "Invalid output: Expected (false) got (${{ steps.changed-files-specific-source-file.outputs.any_deleted }})"
exit 1
fi
shell:
bash
- name: Show output
run: |
echo "${{ toJSON(steps.changed-files-specific.outputs) }}"
echo '${{ toJSON(steps.changed-files-specific-source-file.outputs) }}'
shell:
bash
- name: Run changed-files with specific files from a source file using a comma separator
@@ -227,18 +341,27 @@ jobs:
files_from_source_file: |
test/changed-files-list.txt
separator: ","
- name: Verify any_changed files comma separator
if: "!contains(steps.changed-files-specific-comma.outputs.all_modified_files, 'action.yml') && !contains(steps.changed-files-specific-comma.outputs.all_modified_files, '.github/workflows/test.yml')"
- name: Show output
run: |
if [[ "${{ steps.changed-files-specific.outputs.any_changed }}" != "false" ]]; then
echo "Invalid output: Expected (false) got (${{ steps.changed-files-specific.outputs.any_changed }})"
echo '${{ toJSON(steps.changed-files-specific-comma-source-file.outputs) }}'
shell:
bash
- name: Verify any_changed files comma separator
if: "!contains(steps.changed-files-specific-comma-source-file.outputs.all_modified_files, 'action.yml') && !contains(steps.changed-files-specific-comma-source-file.outputs.all_modified_files, '.github/workflows/test.yml')"
run: |
if [[ "${{ steps.changed-files-specific-comma-source-file.outputs.any_changed }}" != "false" ]]; then
echo "Invalid output: Expected (false) got (${{ steps.changed-files-specific-comma-source-file.outputs.any_changed }})"
exit 1
fi
shell:
bash
- name: Show output
- name: Verify any_deleted files with comma separator
if: "!contains(steps.changed-files-specific-comma-source-file.outputs.deleted_files, 'action.yml') && !contains(steps.changed-files-specific-comma-source-file.outputs.deleted_files, '.github/workflows/test.yml')"
run: |
echo "${{ toJSON(steps.changed-files-specific-comma.outputs) }}"
if [[ "${{ steps.changed-files-specific-comma-source-file.outputs.any_deleted }}" != "false" ]]; then
echo "Invalid output: Expected (false) got (${{ steps.changed-files-specific-comma-source-file.outputs.any_deleted }})"
exit 1
fi
shell:
bash
- name: Run changed-files with custom sha
@@ -248,7 +371,7 @@ jobs:
sha: ${{ github.event.pull_request.head.sha }}
- name: Show output
run: |
echo "${{ toJSON(steps.changed-files-custom-sha.outputs) }}"
echo '${{ toJSON(steps.changed-files-custom-sha.outputs) }}'
shell:
bash
- name: Get branch name
@@ -267,7 +390,7 @@ jobs:
base_sha: ${{ steps.last_successful_commit.outputs.commit_hash }}
- name: Show output
run: |
echo "${{ toJSON(steps.changed-files-custom-base-sha.outputs) }}"
echo '${{ toJSON(steps.changed-files-custom-base-sha.outputs) }}'
shell:
bash
- name: Run changed-files with specific files (only-changed)
@@ -285,8 +408,17 @@ jobs:
fi
shell:
bash
- name: Show output
- name: Verify only_deleted files
if: steps.changed-files-specific-only-changed.outputs.other_deleted_files != ''
run: |
echo "${{ toJSON(steps.changed-files-specific-only-changed.outputs) }}"
if [[ "${{ steps.changed-files-specific-only-changed.outputs.only_deleted }}" != "false" ]]; then
echo "Invalid output: Expected (false) got (${{ steps.changed-files-specific-only-changed.outputs.only_deleted }})"
exit 1
fi
shell:
bash
- name: Show output
run: |
echo '${{ toJSON(steps.changed-files-specific-only-changed.outputs) }}'
shell:
bash

View File

@@ -22,11 +22,13 @@ jobs:
with:
files: |
README.md
- name: README.md changed
if: steps.verify_changed_files.outputs.files_changed == 'true'
run: |
echo "README.md has uncommited changes"
exit 1
- name: Create Pull Request
if: failure()
uses: peter-evans/create-pull-request@v3

View File

@@ -1,5 +1,66 @@
# Changelog
## [v1.1.1](https://github.com/tj-actions/changed-files/tree/v1.1.1) (2021-09-05)
[Full Changelog](https://github.com/tj-actions/changed-files/compare/v1.1.0...v1.1.1)
**Implemented enhancements:**
- \[Feature\] Rename `all_changed_files` to `all_changed_and_modified_files` [\#179](https://github.com/tj-actions/changed-files/issues/179)
- \[Feature\] Add support for `any_deleted` and `only_deleted` boolean output. [\#166](https://github.com/tj-actions/changed-files/issues/166)
**Merged pull requests:**
- Added support for detecting deleted files. [\#188](https://github.com/tj-actions/changed-files/pull/188) ([jackton1](https://github.com/jackton1))
- Rename all\_changed\_files to all\_changed\_and\_modified\_files. [\#187](https://github.com/tj-actions/changed-files/pull/187) ([jackton1](https://github.com/jackton1))
- Update other\_changed\_files output to also use the separator [\#186](https://github.com/tj-actions/changed-files/pull/186) ([jackton1](https://github.com/jackton1))
- Upgraded to v1.1.0 [\#185](https://github.com/tj-actions/changed-files/pull/185) ([jackton1](https://github.com/jackton1))
## [v1.1.0](https://github.com/tj-actions/changed-files/tree/v1.1.0) (2021-09-04)
[Full Changelog](https://github.com/tj-actions/changed-files/compare/v1.0.3...v1.1.0)
**Implemented enhancements:**
- \[Feature\] Specify sed delimiter or escaping forward slashes used in separator [\#180](https://github.com/tj-actions/changed-files/issues/180)
**Closed issues:**
- Dependency Dashboard [\#27](https://github.com/tj-actions/changed-files/issues/27)
**Merged pull requests:**
- Update pascalgn/automerge-action action to v0.14.3 [\#184](https://github.com/tj-actions/changed-files/pull/184) ([renovate[bot]](https://github.com/apps/renovate))
- Upgraded to v1.0.3 [\#183](https://github.com/tj-actions/changed-files/pull/183) ([jackton1](https://github.com/jackton1))
- Update handling separator. [\#181](https://github.com/tj-actions/changed-files/pull/181) ([jackton1](https://github.com/jackton1))
## [v1.0.3](https://github.com/tj-actions/changed-files/tree/v1.0.3) (2021-09-03)
[Full Changelog](https://github.com/tj-actions/changed-files/compare/v1.0.2...v1.0.3)
**Implemented enhancements:**
- \[Feature\] Documentation for difference between all\_changed\_files and all\_modified\_files [\#177](https://github.com/tj-actions/changed-files/issues/177)
**Merged pull requests:**
- Update removing trailing separator [\#182](https://github.com/tj-actions/changed-files/pull/182) ([jackton1](https://github.com/jackton1))
- Update README.md [\#178](https://github.com/tj-actions/changed-files/pull/178) ([jackton1](https://github.com/jackton1))
- Upgraded to v1.0.2 [\#176](https://github.com/tj-actions/changed-files/pull/176) ([jackton1](https://github.com/jackton1))
## [v1.0.2](https://github.com/tj-actions/changed-files/tree/v1.0.2) (2021-08-28)
[Full Changelog](https://github.com/tj-actions/changed-files/compare/v1.0.1...v1.0.2)
**Fixed bugs:**
- \[BUG\] Error: xargs: unmatched single quote [\#169](https://github.com/tj-actions/changed-files/issues/169)
**Merged pull requests:**
- Fixed bug with parsing filenames that contain quotes [\#174](https://github.com/tj-actions/changed-files/pull/174) ([jackton1](https://github.com/jackton1))
- Upgraded to v1.0.1 [\#173](https://github.com/tj-actions/changed-files/pull/173) ([jackton1](https://github.com/jackton1))
## [v1.0.1](https://github.com/tj-actions/changed-files/tree/v1.0.1) (2021-08-28)
[Full Changelog](https://github.com/tj-actions/changed-files/compare/v1.0.0...v1.0.1)
@@ -13,10 +74,6 @@
- \[BUG\] Deleted files not detected [\#165](https://github.com/tj-actions/changed-files/issues/165)
- \[BUG\] changed-files unable to initialize git repository on custom container image [\#164](https://github.com/tj-actions/changed-files/issues/164)
**Closed issues:**
- Dependency Dashboard [\#27](https://github.com/tj-actions/changed-files/issues/27)
**Merged pull requests:**
- Updated README.md [\#172](https://github.com/tj-actions/changed-files/pull/172) ([jackton1](https://github.com/jackton1))

View File

@@ -57,7 +57,7 @@ jobs:
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v1.0.1
uses: tj-actions/changed-files@v1.1.1
- name: List all modified files
run: |
@@ -83,9 +83,11 @@ jobs:
|:--------------------:|:------------:|:----------------------------------:|:----------------------------------------:|
| any_changed | `string` | `true` OR `false` | Returns `true` when any <br /> of the filenames provided using <br /> the `files` input has changed. <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 have changed. |
| other_changed_files | `string` | `'new.txt path/to/file.png ...'` | Select all modified files <br/> not listed in the files input <br /> i.e. *a combination of all added, <br /> copied and modified files (ACM).* |
| any_deleted | `string` | `true` OR `false` | Returns `true` when any <br /> of the filenames provided using <br /> the `files` input has been deleted. |
| only_deleted | `string` | `true` OR `false` | Returns `true` when only <br /> files provided using <br /> the `files` input has been deleted. |
| other_changed_files | `string` | `'new.txt path/to/file.png ...'` | Select all other changed files <br/> not listed in the files input <br /> i.e. *a combination of all added, <br /> copied and modified files (ACMR).* |
| all_modified_files | `string` | `'new.txt path/to/file.png ...'` | Select all modified files <br /> i.e. *a combination of all added, <br />copied, modified and renamed files (ACMR).* |
| all_changed_files | `string` | `'new.txt path/to/file.png ...'` | Select all paths (\*) <br /> i.e. *a combination of all options below.* |
| all_changed_and_modified_files | `string` | `'new.txt path/to/file.png ...'` | Select all changed <br /> and modified files <br /> i.e. *a combination of (ACMRDTUX).* |
| added_files | `string` | `'new.txt path/to/file.png ...'` | Select only files that are Added (A) |
| copied_files | `string` | `'new.txt path/to/file.png ...'` | Select only files that are Copied (C) |
| deleted_files | `string` | `'new.txt path/to/file.png ...'` | Select only files that are Deleted (D) |
@@ -116,11 +118,11 @@ jobs:
- name: Get changed files using defaults
id: changed-files
uses: tj-actions/changed-files@v1.0.1
uses: tj-actions/changed-files@v1.1.1
- name: Get changed files using a comma separator
id: changed-files-comma
uses: tj-actions/changed-files@v1.0.1
uses: tj-actions/changed-files@v1.1.1
with:
separator: ","
@@ -142,7 +144,7 @@ jobs:
- name: Get specific changed files
id: changed-files-specific
uses: tj-actions/changed-files@v1.0.1
uses: tj-actions/changed-files@v1.1.1
with:
files: |
my-file.txt
@@ -164,16 +166,30 @@ jobs:
run: |
echo "Only files listed above have changed."
- name: Run step if any of the listed files above is 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 if all listed files above 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
- name: Use a source file or list of file(s) to populate to files input.
id: changed-files-specific-source-file
uses: tj-actions/changed-files@v1.0.1
uses: tj-actions/changed-files@v1.1.1
with:
files_from_source_file: |
test/changed-files-list.txt
- name: Use 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@v1.0.1
uses: tj-actions/changed-files@v1.1.1
with:
files_from_source_file: |
test/changed-files-list.txt
@@ -182,13 +198,13 @@ jobs:
- name: Use a different commit SHA
id: changed-files-custom-sha
uses: tj-actions/changed-files@v1.0.1
uses: tj-actions/changed-files@v1.1.1
with:
sha: ${{ github.event.pull_request.head.sha }}
- name: Use a different base SHA
id: changed-files-custom-base-sha
uses: tj-actions/changed-files@v1.0.1
uses: tj-actions/changed-files@v1.1.1
with:
base_sha: "2096ed0"
@@ -200,10 +216,9 @@ jobs:
- name: Run changed-files with defaults on the dir1
id: changed-files-for-subfolder
uses: tj-actions/changed-files@v1.0.1
uses: tj-actions/changed-files@v1.1.1
with:
path: subfolder
```
### Running [pre-commit](https://pre-commit.com/) on all modified files
@@ -217,7 +232,7 @@ jobs:
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v1.0.1
uses: tj-actions/changed-files@v1.1.1
- name: Pre-commit
uses: pre-commit/action@v2.0.0

View File

@@ -54,9 +54,9 @@ outputs:
unknown_files:
description: List of unknown files.
value: ${{ steps.changed-files.outputs.unknown_files }}
all_changed_files:
all_changed_and_modified_files:
description: List of all changed files.
value: ${{ steps.changed-files.outputs.all_changed_files }}
value: ${{ steps.changed-files.outputs.all_changed_and_modified_files }}
all_modified_files:
description: List of all copied modified and added files.
value: ${{ steps.changed-files.outputs.all_modified_files }}
@@ -64,26 +64,26 @@ outputs:
description: Return true only when any files provided using the files input have changed.
value: ${{ steps.changed-files.outputs.any_changed }}
only_changed:
description: Return true only when only files provided using the files input have changed.
description: Return true when all files provided using the files input have changed.
value: ${{ steps.changed-files.outputs.only_changed }}
other_changed_files:
description: Return list of changed files not listed in the files input.
value: ${{ steps.changed-files.outputs.other_changed_files }}
any_deleted:
description: Return true only when any files provided using the files input have been deleted.
value: ${{ steps.changed-files.outputs.any_deleted }}
only_deleted:
description: Return true when all files provided using the files input have been deleted.
value: ${{ steps.changed-files.outputs.only_deleted }}
other_deleted_files:
description: Return list of deleted files not listed in the files input.
value: ${{ steps.changed-files.outputs.other_deleted_files }}
runs:
using: 'composite'
steps:
- run: |
FILES=()
if [[ -n $INPUT_FILES_FROM_SOURCE_FILE ]]; then
for file in $INPUT_FILES_FROM_SOURCE_FILE
do
FILES+=$(cat $file | sort -u | tr "\n" " " )
done
fi
echo "::set-output name=files::$FILES"
bash $GITHUB_ACTION_PATH/sourcefiles.sh
id: source-input-files
shell: bash
env:
@@ -101,7 +101,7 @@ runs:
INPUT_SHA: ${{ inputs.sha }}
INPUT_BASE_SHA: ${{ inputs.base_sha }}
INPUT_TOKEN: ${{ inputs.token }}
INPUT_FILES: ${{ join(format('{0} {1}', inputs.files, steps.source-input-files.outputs.files), ' ') }}
INPUT_FILES: ${{ steps.source-input-files.outputs.files }}
INPUT_SEPARATOR: ${{ inputs.separator }}
INPUT_PATH: ${{ inputs.path }}

View File

@@ -62,20 +62,18 @@ fi
echo "Retrieving changes between $PREVIOUS_SHA ($TARGET_BRANCH) → $CURRENT_SHA ($CURRENT_BRANCH)"
UNIQUE_FILES=$(echo "$INPUT_FILES" | tr " " "\n" | sort -u | xargs -0)
if [[ -z "$UNIQUE_FILES" ]]; then
if [[ -z "${INPUT_FILES[*]}" ]]; then
echo "Getting diff..."
ADDED=$(git diff --diff-filter=A --name-only "$PREVIOUS_SHA" "$CURRENT_SHA" | tr "\n" "$INPUT_SEPARATOR" | sed -E "s/($INPUT_SEPARATOR)$//")
COPIED=$(git diff --diff-filter=C --name-only "$PREVIOUS_SHA" "$CURRENT_SHA" | tr "\n" "$INPUT_SEPARATOR" | sed -E "s/($INPUT_SEPARATOR)$//")
DELETED=$(git diff --diff-filter=D --name-only "$PREVIOUS_SHA" "$CURRENT_SHA" | tr "\n" "$INPUT_SEPARATOR" | sed -E "s/($INPUT_SEPARATOR)$//")
MODIFIED=$(git diff --diff-filter=M --name-only "$PREVIOUS_SHA" "$CURRENT_SHA" | tr "\n" "$INPUT_SEPARATOR" | sed -E "s/($INPUT_SEPARATOR)$//")
RENAMED=$(git diff --diff-filter=R --name-only "$PREVIOUS_SHA" "$CURRENT_SHA" | tr "\n" "$INPUT_SEPARATOR" | sed -E "s/($INPUT_SEPARATOR)$//")
TYPE_CHANGED=$(git diff --diff-filter=T --name-only "$PREVIOUS_SHA" "$CURRENT_SHA" | tr "\n" "$INPUT_SEPARATOR" | sed -E "s/($INPUT_SEPARATOR)$//")
UNMERGED=$(git diff --diff-filter=U --name-only "$PREVIOUS_SHA" "$CURRENT_SHA" | tr "\n" "$INPUT_SEPARATOR" | sed -E "s/($INPUT_SEPARATOR)$//")
UNKNOWN=$(git diff --diff-filter=X --name-only "$PREVIOUS_SHA" "$CURRENT_SHA" | tr "\n" "$INPUT_SEPARATOR" | sed -E "s/($INPUT_SEPARATOR)$//")
ALL_CHANGED=$(git diff --diff-filter="*ACDMRTUX" --name-only "$PREVIOUS_SHA" "$CURRENT_SHA" | tr "\n" "$INPUT_SEPARATOR" | sed -E "s/($INPUT_SEPARATOR)$//")
ALL_MODIFIED_FILES=$(git diff --diff-filter="ACMR" --name-only "$PREVIOUS_SHA" "$CURRENT_SHA" | tr "\n" "$INPUT_SEPARATOR" | sed -E "s/($INPUT_SEPARATOR)$//")
ADDED=$(git diff --diff-filter=A --name-only "$PREVIOUS_SHA" "$CURRENT_SHA" | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}')
COPIED=$(git diff --diff-filter=C --name-only "$PREVIOUS_SHA" "$CURRENT_SHA" | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}')
DELETED=$(git diff --diff-filter=D --name-only "$PREVIOUS_SHA" "$CURRENT_SHA" | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}')
MODIFIED=$(git diff --diff-filter=M --name-only "$PREVIOUS_SHA" "$CURRENT_SHA" | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}')
RENAMED=$(git diff --diff-filter=R --name-only "$PREVIOUS_SHA" "$CURRENT_SHA" | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}')
TYPE_CHANGED=$(git diff --diff-filter=T --name-only "$PREVIOUS_SHA" "$CURRENT_SHA" | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}')
UNMERGED=$(git diff --diff-filter=U --name-only "$PREVIOUS_SHA" "$CURRENT_SHA" | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}')
UNKNOWN=$(git diff --diff-filter=X --name-only "$PREVIOUS_SHA" "$CURRENT_SHA" | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}')
ALL_CHANGED_AND_MODIFIED=$(git diff --diff-filter="*ACDMRTUX" --name-only "$PREVIOUS_SHA" "$CURRENT_SHA" | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}')
ALL_MODIFIED_FILES=$(git diff --diff-filter="ACMR" --name-only "$PREVIOUS_SHA" "$CURRENT_SHA" | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}')
else
ADDED_ARRAY=()
COPIED_ARRAY=()
@@ -88,7 +86,9 @@ else
ALL_CHANGED_ARRAY=()
ALL_MODIFIED_FILES_ARRAY=()
for path in ${UNIQUE_FILES}
echo "Input files: ${INPUT_FILES[*]}"
for path in ${INPUT_FILES}
do
echo "Checking for file changes: \"${path}\"..."
IFS=" "
@@ -114,26 +114,62 @@ else
ALL_MODIFIED_FILES_ARRAY+=($(git diff --diff-filter="ACMR" --name-only "$PREVIOUS_SHA" "$CURRENT_SHA" | grep -E "(${path})" | xargs -0 || true))
done
# shellcheck disable=SC2001
ADDED=$(echo "${ADDED_ARRAY[*]}" | sed 's/ */'"$INPUT_SEPARATOR"'/g' | tr " " "\n" | sort -u | xargs -0)
# shellcheck disable=SC2001
COPIED=$(echo "${COPIED_ARRAY[*]}" | sed 's/ */'"$INPUT_SEPARATOR"'/g' | tr " " "\n" | sort -u | xargs -0)
# shellcheck disable=SC2001
DELETED=$(echo "${DELETED_ARRAY[*]}" | sed 's/ */'"$INPUT_SEPARATOR"'/g' | tr " " "\n" | sort -u | xargs -0)
# shellcheck disable=SC2001
MODIFIED=$(echo "${MODIFIED_ARRAY[*]}" | sed 's/ */'"$INPUT_SEPARATOR"'/g' | tr " " "\n" | sort -u | xargs -0)
# shellcheck disable=SC2001
RENAMED=$(echo "${RENAMED_ARRAY[*]}" | sed 's/ */'"$INPUT_SEPARATOR"'/g' | tr " " "\n" | sort -u | xargs -0)
# shellcheck disable=SC2001
TYPE_CHANGED=$(echo "${TYPE_CHANGED_ARRAY[*]}" | sed 's/ */'"$INPUT_SEPARATOR"'/g' | tr " " "\n" | sort -u | xargs -0)
# shellcheck disable=SC2001
UNMERGED=$(echo "${UNMERGED_ARRAY[*]}" | sed 's/ */'"$INPUT_SEPARATOR"'/g' | tr " " "\n" | sort -u | xargs -0)
# shellcheck disable=SC2001
UNKNOWN=$(echo "${UNKNOWN_ARRAY[*]}" | sed 's/ */'"$INPUT_SEPARATOR"'/g' | tr " " "\n" | sort -u | xargs -0)
# shellcheck disable=SC2001
ALL_CHANGED=$(echo "${ALL_CHANGED_ARRAY[*]}" | sed 's/ */'"$INPUT_SEPARATOR"'/g' | tr " " "\n" | sort -u | xargs -0)
# shellcheck disable=SC2001
ALL_MODIFIED_FILES=$(echo "${ALL_MODIFIED_FILES_ARRAY[*]}" | sed 's/ */'"$INPUT_SEPARATOR"'/g' | tr " " "\n" | sort -u | xargs -0)
ADDED=$(echo "${ADDED_ARRAY[*]}" | tr " " "\n" | sort -u | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}')
COPIED=$(echo "${COPIED_ARRAY[*]}" | tr " " "\n" | sort -u | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}')
DELETED=$(echo "${DELETED_ARRAY[*]}" | tr " " "\n" | sort -u | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}')
MODIFIED=$(echo "${MODIFIED_ARRAY[*]}" | tr " " "\n" | sort -u | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}')
RENAMED=$(echo "${RENAMED_ARRAY[*]}" | tr " " "\n" | sort -u | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}')
TYPE_CHANGED=$(echo "${TYPE_CHANGED_ARRAY[*]}" | tr " " "\n" | sort -u | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}')
UNMERGED=$(echo "${UNMERGED_ARRAY[*]}" | tr " " "\n" | sort -u | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}')
UNKNOWN=$(echo "${UNKNOWN_ARRAY[*]}" | tr " " "\n" | sort -u | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}')
ALL_CHANGED_AND_MODIFIED=$(echo "${ALL_CHANGED_ARRAY[*]}" | tr " " "\n" | sort -u | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}')
ALL_MODIFIED_FILES=$(echo "${ALL_MODIFIED_FILES_ARRAY[*]}" | tr " " "\n" | sort -u | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}')
ALL_OTHER_MODIFIED_FILES=$(git diff --diff-filter="ACMR" --name-only "$PREVIOUS_SHA" "$CURRENT_SHA")
IFS=" " read -r -a UNIQUE_ALL_MODIFIED_FILES_ARRAY <<< "$(echo "${ALL_MODIFIED_FILES_ARRAY[*]}" | tr " " "\n" | sort -u | tr "\n" " ")"
IFS=" " read -r -a OTHER_MODIFIED_FILES_ARRAY <<< "$(echo "${ALL_OTHER_MODIFIED_FILES[@]}" "${UNIQUE_ALL_MODIFIED_FILES_ARRAY[@]}" | tr " " "\n" | sort | uniq -u | tr "\n" " ")"
OTHER_MODIFIED_FILES=$(echo "${OTHER_MODIFIED_FILES_ARRAY[*]}" | tr " " "\n" | sort -u | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}')
echo "Matching modified files: ${UNIQUE_ALL_MODIFIED_FILES_ARRAY[*]}"
if [[ -n "${UNIQUE_ALL_MODIFIED_FILES_ARRAY[*]}" ]]; then
echo "::set-output name=any_changed::true"
else
echo "::set-output name=any_changed::false"
fi
if [[ -n "${OTHER_MODIFIED_FILES_ARRAY[*]}" ]]; then
echo "Non Matching modified files: ${OTHER_MODIFIED_FILES_ARRAY[*]}"
echo "::set-output name=only_changed::false"
echo "::set-output name=other_changed_files::$OTHER_MODIFIED_FILES"
elif [[ -n "${UNIQUE_ALL_MODIFIED_FILES_ARRAY[*]}" ]]; then
echo "::set-output name=only_changed::true"
fi
OTHER_DELETED_FILES=$(git diff --diff-filter=D --name-only "$PREVIOUS_SHA" "$CURRENT_SHA")
IFS=" " read -r -a UNIQUE_DELETED_FILES_ARRAY <<< "$(echo "${DELETED_ARRAY[*]}" | tr " " "\n" | sort -u | tr "\n" " ")"
IFS=" " read -r -a OTHER_DELETED_FILES_ARRAY <<< "$(echo "${OTHER_DELETED_FILES[@]}" "${UNIQUE_DELETED_FILES_ARRAY[@]}" | tr " " "\n" | sort | uniq -u | tr "\n" " ")"
OTHER_DELETED_FILES=$(echo "${OTHER_DELETED_FILES_ARRAY[*]}" | tr " " "\n" | sort -u | awk -v d="$INPUT_SEPARATOR" '{s=(NR==1?s:s d)$0}END{print s}')
echo "Matching deleted files: ${UNIQUE_DELETED_FILES_ARRAY[*]}"
if [[ -n "${UNIQUE_DELETED_FILES_ARRAY[*]}" ]]; then
echo "::set-output name=any_deleted::true"
else
echo "::set-output name=any_deleted::false"
fi
if [[ -n "${OTHER_DELETED_FILES_ARRAY[*]}" ]]; then
echo "Non Matching deleted files: ${OTHER_DELETED_FILES_ARRAY[*]}"
echo "::set-output name=only_deleted::false"
echo "::set-output name=other_deleted_files::$OTHER_DELETED_FILES"
elif [[ -n "${UNIQUE_DELETED_FILES_ARRAY[*]}" ]]; then
echo "::set-output name=only_deleted::true"
fi
fi
echo "Added files: $ADDED"
@@ -144,35 +180,9 @@ echo "Renamed files: $RENAMED"
echo "Type Changed files: $TYPE_CHANGED"
echo "Unmerged files: $UNMERGED"
echo "Unknown files: $UNKNOWN"
echo "All changed files: $ALL_CHANGED"
echo "All changed files: $ALL_CHANGED_AND_MODIFIED"
echo "All modified files: $ALL_MODIFIED_FILES"
if [[ -n "$UNIQUE_FILES" ]]; then
# shellcheck disable=SC2001
ALL_INPUT_FILES=$(echo "$UNIQUE_FILES" | tr "\n" " " | xargs -0)
ALL_OTHER_CHANGED_FILES=$(git diff --diff-filter="ACMR" --name-only "$PREVIOUS_SHA" "$CURRENT_SHA")
OTHER_CHANGED_FILES=$(echo "${ALL_OTHER_CHANGED_FILES[@]}" "${ALL_MODIFIED_FILES[@]}" | tr " " "\n" | sort | uniq -u | tr "\n" " " | xargs -0)
echo "Input files: ${ALL_INPUT_FILES[*]}"
echo "Matching modified files: ${ALL_MODIFIED_FILES[*]}"
if [[ -n "$ALL_MODIFIED_FILES" ]]; then
echo "::set-output name=any_changed::true"
else
echo "::set-output name=any_changed::false"
fi
if [[ -n "$OTHER_CHANGED_FILES" ]]; then
echo "Non Matching modified files: ${OTHER_CHANGED_FILES[*]}"
echo "::set-output name=only_changed::false"
echo "::set-output name=other_changed_files::$OTHER_CHANGED_FILES"
else
echo "::set-output name=only_changed::true"
fi
fi
git remote remove temp_changed_files
echo "::set-output name=added_files::$ADDED"
@@ -183,7 +193,7 @@ echo "::set-output name=renamed_files::$RENAMED"
echo "::set-output name=type_changed_files::$TYPE_CHANGED"
echo "::set-output name=unmerged_files::$UNMERGED"
echo "::set-output name=unknown_files::$UNKNOWN"
echo "::set-output name=all_changed_files::$ALL_CHANGED"
echo "::set-output name=all_changed_and_modified_files::$ALL_CHANGED_AND_MODIFIED"
echo "::set-output name=all_modified_files::$ALL_MODIFIED_FILES"
echo "::endgroup::"

26
sourcefiles.sh Normal file
View File

@@ -0,0 +1,26 @@
#!/usr/bin/env bash
set -e
echo "::group::changed-files-from-source-file"
IFS=" " read -r -a FILES <<< "$(echo "${INPUT_FILES[@]}" | sort -u | tr "\n" " ")"
if [[ -n $INPUT_FILES_FROM_SOURCE_FILE ]]; then
for file in $INPUT_FILES_FROM_SOURCE_FILE
do
while read -r fileName; do
FILES+=("$fileName")
done <"$file"
done
fi
echo "Input Files: ${FILES[*]}"
IFS=" " read -r -a ALL_UNIQUE_FILES <<< "$(echo "${FILES[@]}" | tr " " "\n" | sort -u | tr "\n" " ")"
echo "All Unique Input files: ${ALL_UNIQUE_FILES[*]}"
echo "::set-output name=files::${ALL_UNIQUE_FILES[*]}"
echo "::endgroup::"

View File

@@ -1 +1 @@
This is a test