Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for running action within a subdirectory #366

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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