Compare commits

..

8 Commits
v8.5 ... v8.6

Author SHA1 Message Date
Tonye Jack
0bd70b7aec Updated README.md (#133)
Co-authored-by: jackton1 <jackton1@users.noreply.github.com>
2021-07-17 10:55:22 -04:00
Tonye Jack
377d0bb796 Update README.md 2021-07-17 10:54:03 -04:00
Tonye Jack
bd55e90a0a Added support for retrieving the files input using a source file. (#132) 2021-07-17 10:51:08 -04:00
Tonye Jack
256e64f4cc Update README.md 2021-07-16 11:29:34 -04:00
Tonye Jack
202fce939f Update action.yml 2021-07-15 06:03:07 -04:00
Tonye Jack
410c5bd269 Update README.md 2021-07-15 06:02:09 -04:00
Tonye Jack
0bdbb6ef89 Update README.md 2021-07-15 06:01:37 -04:00
Tonye Jack
7d8b8c4fb3 Upgraded to v8.5 (#129)
Co-authored-by: jackton1 <jackton1@users.noreply.github.com>
2021-07-14 17:18:35 -04:00
6 changed files with 117 additions and 18 deletions

View File

@@ -125,6 +125,45 @@ jobs:
fi
shell:
bash
- name: Run changed-files with specific files from a source file
id: changed-files-specific-source-file
uses: ./
with:
files-from-source-file: |
test/changed-files-list.txt
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')"
run: |
if [[ "${{ steps.changed-files-specific.outputs.any_changed }}" != "false" ]]; then
echo "Invalid output: Expected (false) got (${{ steps.changed-files-specific.outputs.any_changed }})"
exit 1
fi
shell:
bash
- name: Show output
run: |
echo "${{ toJSON(steps.changed-files-specific.outputs) }}"
shell:
bash
- name: Run changed-files with specific files from a source file using a comma separator
id: changed-files-specific-comma-source-file
uses: ./
with:
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')"
run: |
if [[ "${{ steps.changed-files-specific.outputs.any_changed }}" != "false" ]]; then
echo "Invalid output: Expected (false) got (${{ steps.changed-files-specific.outputs.any_changed }})"
exit 1
fi
shell:
bash
- name: Show output
run: |
echo "${{ toJSON(steps.changed-files-specific-comma.outputs) }}"

View File

@@ -1,5 +1,19 @@
# Changelog
## [v8.5](https://github.com/tj-actions/changed-files/tree/v8.5) (2021-07-14)
[Full Changelog](https://github.com/tj-actions/changed-files/compare/v8.4...v8.5)
**Merged pull requests:**
- Updated README.md [\#128](https://github.com/tj-actions/changed-files/pull/128) ([jackton1](https://github.com/jackton1))
- docs: add Kras4ooo as a contributor for code, doc [\#127](https://github.com/tj-actions/changed-files/pull/127) ([allcontributors[bot]](https://github.com/apps/allcontributors))
- Add custom source sha [\#126](https://github.com/tj-actions/changed-files/pull/126) ([Kras4ooo](https://github.com/Kras4ooo))
- Updated README.md [\#123](https://github.com/tj-actions/changed-files/pull/123) ([jackton1](https://github.com/jackton1))
- Updated README.md [\#122](https://github.com/tj-actions/changed-files/pull/122) ([jackton1](https://github.com/jackton1))
- Updated README.md [\#120](https://github.com/tj-actions/changed-files/pull/120) ([jackton1](https://github.com/jackton1))
- Upgraded to v8.4 [\#119](https://github.com/tj-actions/changed-files/pull/119) ([jackton1](https://github.com/jackton1))
## [v8.4](https://github.com/tj-actions/changed-files/tree/v8.4) (2021-06-26)
[Full Changelog](https://github.com/tj-actions/changed-files/compare/v8.3...v8.4)

View File

@@ -55,7 +55,7 @@ jobs:
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v8.4
uses: tj-actions/changed-files@v8.5
- name: List all modified files
run: |
@@ -98,6 +98,8 @@ jobs:
| token | `string` | `false` | `${{ github.token }}` | [GITHUB_TOKEN](https://docs.github.com/en/free-pro-team@latest/actions/reference/authentication-in-a-workflow#using-the-github_token-in-a-workflow) <br /> or a repo scoped <br /> [Personal Access Token](https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/creating-a-personal-access-token) |
| separator | `string` | `true` | `' '` | Output string separator |
| files | `string` OR `string[]` | `false` | | Check for changes <br> using only these list of file(s) <br> (Defaults to the entire repo) |
| sha | `string` | `true` | `${{ github.sha }}` | Specify a different <br> commit SHA used for comparing changes |
| files-from-source-file | `string` | `false` | | Source file used populate <br> the files input. |
## Example
@@ -108,11 +110,11 @@ jobs:
- name: Get changed files using defaults
id: changed-files
uses: tj-actions/changed-files@v8.4
uses: tj-actions/changed-files@v8.5
- name: Get changed files using a comma separator
id: changed-files-comma
uses: tj-actions/changed-files@v8.4
uses: tj-actions/changed-files@v8.5
with:
separator: ","
@@ -134,7 +136,7 @@ jobs:
- name: Get specific changed files
id: changed-files-specific
uses: tj-actions/changed-files@v8.4
uses: tj-actions/changed-files@v8.5
with:
files: |
my-file.txt
@@ -145,13 +147,30 @@ jobs:
.(sql)$
^(mynewfile|custom)
- 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: Use a different commit SHA as the base
- 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: Use a source file or list of file(s) to populate to files input.
id: changed-files-specific-source-file
uses: ./
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: ./
with:
files-from-source-file: |
test/changed-files-list.txt
files: |
.github/workflows/rebase.yml
- name: Use a different commit SHA
id: changed-files-comma
uses: tj-actions/changed-files@v8.4
uses: tj-actions/changed-files@v8.5
with:
sha: ${{ github.event.pull_request.head.sha }}
@@ -168,7 +187,7 @@ jobs:
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v8.4
uses: tj-actions/changed-files@v8.5
- name: Pre-commit
uses: pre-commit/action@v2.0.0
@@ -181,7 +200,7 @@ jobs:
![Screen Shot 2021-07-06 at 2 50 23 PM](https://user-images.githubusercontent.com/17484350/124651978-96ed5280-de69-11eb-86d5-396a4c1a980f.png)
![Screen Shot 2021-07-06 at 2 46 00 PM](https://user-images.githubusercontent.com/17484350/124651480-f8f98800-de68-11eb-954c-6c0e09a9de6d.png)
![Screen Shot 2021-07-17 at 10 52 48 AM](https://user-images.githubusercontent.com/17484350/126040772-30b65afb-a6b5-4150-b312-ac2017ba7b98.png)
* Free software: [MIT license](LICENSE)

View File

@@ -10,12 +10,16 @@ inputs:
description: 'Split character for array output'
required: true
default: " "
files-from-source-file:
description: 'Source file to populate the files input'
required: false
default: ""
files:
description: 'Check for changes using only this list of files (Defaults to the entire repo)'
required: false
default: ""
sha:
description: 'Specify a different commit SHA to be used for comparing changes'
description: 'Specify a different commit SHA used for comparing changes'
required: true
default: ${{ github.sha }}
@@ -57,6 +61,22 @@ outputs:
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"
id: source-input-files
shell: bash
env:
INPUT_FILES: ${{ inputs.files }}
INPUT_FILES_FROM_SOURCE_FILE: ${{ inputs.files-from-source-file }}
- run: |
bash $GITHUB_ACTION_PATH/entrypoint.sh
id: changed-files
@@ -68,7 +88,7 @@ runs:
# https://github.community/t/input-variable-name-is-not-available-in-composite-run-steps/127611
INPUT_SHA: ${{ inputs.sha }}
INPUT_TOKEN: ${{ inputs.token }}
INPUT_FILES: ${{ inputs.files }}
INPUT_FILES: ${{ join(format('{0} {1}', inputs.files, steps.source-input-files.outputs.files), ' ') }}
INPUT_SEPARATOR: ${{ inputs.separator }}
branding:

View File

@@ -43,7 +43,9 @@ fi
echo "Retrieving changes between $PREV_SHA ($TARGET_BRANCH) → $CURR_SHA ($CURRENT_BRANCH)"
if [[ -z "$INPUT_FILES" ]]; then
UNIQUE_FILES=$(echo "$INPUT_FILES" | tr ' ' '\n' | sort -u | xargs)
if [[ -z "$UNIQUE_FILES" ]]; then
echo "Getting diff..."
ADDED=$(git diff --diff-filter=A --name-only "$PREV_SHA" "$CURR_SHA" | tr "\n" "$INPUT_SEPARATOR" | sed -E "s/($INPUT_SEPARATOR)$//")
COPIED=$(git diff --diff-filter=C --name-only "$PREV_SHA" "$CURR_SHA" | tr "\n" "$INPUT_SEPARATOR" | sed -E "s/($INPUT_SEPARATOR)$//")
@@ -66,7 +68,8 @@ else
UNKNOWN_ARRAY=()
ALL_CHANGED_ARRAY=()
ALL_MODIFIED_FILES_ARRAY=()
for path in ${INPUT_FILES}
for path in ${UNIQUE_FILES}
do
echo "Checking for file changes: \"${path}\"..."
IFS=" "
@@ -125,9 +128,9 @@ echo "Unknown files: $UNKNOWN"
echo "All changed files: $ALL_CHANGED"
echo "All modified files: $ALL_MODIFIED_FILES"
if [[ -n "$INPUT_FILES" ]]; then
if [[ -n "$UNIQUE_FILES" ]]; then
# shellcheck disable=SC2001
ALL_INPUT_FILES=$(echo "$INPUT_FILES" | tr "\n" " " | xargs)
ALL_INPUT_FILES=$(echo "$UNIQUE_FILES" | tr "\n" " " | xargs)
echo "Input files: ${ALL_INPUT_FILES[*]}"
echo "Matching modified files: ${ALL_MODIFIED_FILES[*]}"

View File

@@ -0,0 +1,4 @@
.github/workflows/test.yml
action.yml
action.yml
test/changed-files-list.txt