Skip to content

Commit

Permalink
feat: add support for running action within a subdirectory (#366)
Browse files Browse the repository at this point in the history
  • Loading branch information
jackton1 committed Jan 19, 2024
1 parent 0e5b383 commit 8182bdd
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/test.yml
Expand Up @@ -65,11 +65,10 @@ jobs:
id: changed_files_expected
with:
separator: '\n'
path: test
files: |
test/*.txt
test/*.sql
test/**/*.txt
test/**/*.sql
*.{txt,sql}
**/*.{txt,sql}
- name: Display changed files
if: steps.changed_files_expected.outputs.files_changed == 'true'
run: |
Expand Down
5 changes: 5 additions & 0 deletions action.yml
Expand Up @@ -29,6 +29,10 @@ inputs:
description: "Apply sanitization to output filenames before being set as output."
required: false
default: "true"
path:
description: "Relative path under GITHUB_WORKSPACE to the repository"
required: false
default: '.'

outputs:
files_changed:
Expand Down Expand Up @@ -67,6 +71,7 @@ runs:
INPUT_FAIL_IF_CHANGED: ${{ inputs.fail-if-changed }}
INPUT_FAIL_MSG: ${{ inputs.fail-message }}
INPUT_SAFE_OUTPUT: ${{ inputs.safe_output }}
INPUT_PATH: ${{ inputs.path }}
branding:
icon: file-text
Expand Down
13 changes: 12 additions & 1 deletion entrypoint.sh
Expand Up @@ -8,9 +8,20 @@ INPUT_SEPARATOR="${INPUT_SEPARATOR//\\n/%0A}"
INPUT_SEPARATOR="${INPUT_SEPARATOR//\\r/%0D}"

echo "::group::verify-changed-files"

echo "::debug::Separator: $INPUT_SEPARATOR"

if [[ -n $INPUT_PATH ]]; then
REPO_DIR="$GITHUB_WORKSPACE/$INPUT_PATH"

echo "Resolving repository path: $REPO_DIR"
if [[ ! -d "$REPO_DIR" ]]; then
echo "::error::Invalid repository path: $REPO_DIR"
echo "::endgroup::"
exit 1
fi
cd "$REPO_DIR"
fi

GIT_STATUS_EXTRA_ARGS="-u --porcelain"

if [[ "$INPUT_MATCH_GITIGNORE_FILES" == "true" ]]; then
Expand Down

0 comments on commit 8182bdd

Please sign in to comment.