diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..1d52e07 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,19 @@ +name: CI + +on: + push: + branches: + - master + pull_request: + branches: + - master + +jobs: + test: + runs-on: ubuntu-latest + name: Test verify-changed-files + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: shellcheck + uses: reviewdog/action-shellcheck@v1 diff --git a/action.yml b/action.yml index edc4b80..ee0ddc6 100644 --- a/action.yml +++ b/action.yml @@ -7,9 +7,8 @@ inputs: required: true default: ${{ github.token }} files: - description: Comma separated list of files to check for changes. - required: false - default: '' + description: List of files to check for changes. + required: true runs: using: 'docker' image: 'Dockerfile' diff --git a/entrypoint.sh b/entrypoint.sh index a299a67..e7635f4 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -2,14 +2,18 @@ set -e -GITHUB_TOKEN=$1 FILES=$2 -echo "Formatting filenames..." -EXPECTED_FILES="$(printf $(echo ${FILES} | sed 's| ||g' | sed 's/,/|/g'))" +CHANGED_FILES=() -echo "Checking changes for \"${EXPECTED_FILES}\"... " -CHANGED_FILES=$(git diff --diff-filter=ACM --name-only | grep -E "(${EXPECTED_FILES})" || true) +for path in ${FILES} +do + echo "Checking for file changes: \"${path}\"..." + MODIFIED_FILE=$(git diff --diff-filter=ACM --name-only | grep -E "(${path})" || true) + if [[ -n ${MODIFIED_FILE} ]]; then + CHANGED_FILES+=("${path}") + fi +done if [[ -z ${CHANGED_FILES} ]]; then echo "::set-output name=files_changed::false"