mirror of
https://github.com/tj-actions/changed-files
synced 2025-02-20 21:01:53 +00:00
Implement path parameter (#168)
* Implement path parameter * Add test * Update README.md * Corrections after code review * Update action.yml * Update test.yml * Do not use realpath * Update entrypoint.sh * Update test.yml Co-authored-by: Ivan Pizhenko <IvanPizhenko@users.noreply.github.com> Co-authored-by: Tonye Jack <jtonye@ymail.com>
This commit is contained in:
parent
fcd69a6202
commit
8a41500fbe
6 changed files with 94 additions and 13 deletions
|
@ -32,6 +32,16 @@
|
|||
"code",
|
||||
"doc"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "IvanPizhenko",
|
||||
"name": "Ivan Pizhenko",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/11859904?v=4",
|
||||
"profile": "https://github.com/IvanPizhenko",
|
||||
"contributions": [
|
||||
"code",
|
||||
"doc"
|
||||
]
|
||||
}
|
||||
],
|
||||
"contributorsPerLine": 7,
|
||||
|
|
53
.github/workflows/test.yml
vendored
53
.github/workflows/test.yml
vendored
|
@ -20,6 +20,59 @@ jobs:
|
|||
- name: shellcheck
|
||||
uses: reviewdog/action-shellcheck@v1.7
|
||||
|
||||
test-multiple-repositories:
|
||||
name: Test with multiple repositories
|
||||
runs-on: ${{ matrix.platform }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
platform: [ubuntu-latest, windows-latest, macos-latest]
|
||||
steps:
|
||||
- name: Checkout into dir1
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
path: dir1
|
||||
- name: Run changed-files with defaults on the dir1
|
||||
id: changed-files-dir1
|
||||
uses: ./dir1
|
||||
with:
|
||||
path: dir1
|
||||
- name: Show output
|
||||
run: |
|
||||
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
|
||||
done
|
||||
shell:
|
||||
bash
|
||||
- name: Checkout into dir2
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
path: dir2
|
||||
- name: Run changed-files with defaults on the dir2
|
||||
id: changed-files-dir2
|
||||
uses: ./dir2
|
||||
with:
|
||||
path: dir2
|
||||
- name: Show output
|
||||
run: |
|
||||
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
|
||||
done
|
||||
shell:
|
||||
bash
|
||||
|
||||
test-no-head-sha:
|
||||
name: Test changed-files missing head sha
|
||||
runs-on: ${{ matrix.platform }}
|
||||
|
|
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,2 +1,4 @@
|
|||
.idea/
|
||||
.envrc
|
||||
tag.sh
|
||||
untag.sh
|
||||
|
|
|
@ -104,6 +104,7 @@ jobs:
|
|||
| base_sha | `string` | `false` | | Specify a different <br> base commit SHA <br> used for <br> comparing changes |
|
||||
| sha | `string` | `true` | `${{ github.sha }}` | Specify a different <br> commit SHA <br> used for <br> comparing changes |
|
||||
| files_from_source_file | `string` | `false` | | Source file <br> used to populate <br> the files input |
|
||||
| path | `string` | `false` | | Relative path under <br> `GITHUB_WORKSPACE` <br> to the repository |
|
||||
|
||||
## Example
|
||||
|
||||
|
|
|
@ -25,6 +25,9 @@ inputs:
|
|||
base_sha:
|
||||
description: 'Specify a base commit SHA on used for comparing changes'
|
||||
required: false
|
||||
path:
|
||||
description: 'Specify a relative path under $GITHUB_WORKSPACE to locate the repository'
|
||||
required: false
|
||||
|
||||
outputs:
|
||||
added_files:
|
||||
|
@ -100,6 +103,7 @@ runs:
|
|||
INPUT_TOKEN: ${{ inputs.token }}
|
||||
INPUT_FILES: ${{ join(format('{0} {1}', inputs.files, steps.source-input-files.outputs.files), ' ') }}
|
||||
INPUT_SEPARATOR: ${{ inputs.separator }}
|
||||
INPUT_PATH: ${{ inputs.path }}
|
||||
|
||||
branding:
|
||||
icon: file-text
|
||||
|
|
|
@ -4,6 +4,17 @@ set -e
|
|||
|
||||
echo "::group::changed-files"
|
||||
|
||||
echo "Resolving repository path..."
|
||||
|
||||
if [[ -n $INPUT_PATH ]]; then
|
||||
REPO_DIR="$GITHUB_WORKSPACE/$INPUT_PATH"
|
||||
if [[ ! -d "$REPO_DIR" ]]; then
|
||||
echo "::warning::Invalid repository path"
|
||||
exit 1
|
||||
fi
|
||||
cd "$REPO_DIR"
|
||||
fi
|
||||
|
||||
git remote add temp_changed_files "https://${INPUT_TOKEN}@github.com/${GITHUB_REPOSITORY}"
|
||||
|
||||
echo "Getting HEAD info..."
|
||||
|
|
Loading…
Add table
Reference in a new issue