diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index cee3c36..50618ac 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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: | diff --git a/action.yml b/action.yml index 06307f1..8150eec 100644 --- a/action.yml +++ b/action.yml @@ -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: @@ -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 diff --git a/entrypoint.sh b/entrypoint.sh index 1d6748b..b0efb74 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -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