Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0bd70b7aec | ||
|
|
377d0bb796 | ||
|
|
bd55e90a0a | ||
|
|
256e64f4cc | ||
|
|
202fce939f | ||
|
|
410c5bd269 | ||
|
|
0bdbb6ef89 | ||
|
|
7d8b8c4fb3 |
39
.github/workflows/test.yml
vendored
39
.github/workflows/test.yml
vendored
@@ -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) }}"
|
||||
|
||||
14
HISTORY.md
14
HISTORY.md
@@ -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)
|
||||
|
||||
43
README.md
43
README.md
@@ -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:
|
||||
|
||||

|
||||
|
||||

|
||||

|
||||
|
||||
* Free software: [MIT license](LICENSE)
|
||||
|
||||
|
||||
24
action.yml
24
action.yml
@@ -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:
|
||||
|
||||
@@ -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[*]}"
|
||||
|
||||
4
test/changed-files-list.txt
Normal file
4
test/changed-files-list.txt
Normal file
@@ -0,0 +1,4 @@
|
||||
.github/workflows/test.yml
|
||||
action.yml
|
||||
action.yml
|
||||
test/changed-files-list.txt
|
||||
Reference in New Issue
Block a user