diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index f26802c597..ad0b677f2d 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -48,23 +48,22 @@ jobs: working-directory: OpenSearch-Dashboards/plugins/${{ env.PLUGIN_NAME }} run: yarn osd bootstrap - - name: Get list of changed files + - name: Get list of changed files using GitHub Action + uses: lots0logs/gh-action-get-changed-files@v1.2 id: files - run: | - BASE_SHA="${{ github.event.pull_request.base.sha }}" - HEAD_SHA="${{ github.event.pull_request.head.sha }}" - git fetch origin $BASE_SHA - git diff --name-only $BASE_SHA...$HEAD_SHA > changed_files.txt - CHANGED_FILES=$(cat changed_files.txt | grep -E '\.(js|ts|tsx)$' || true) - echo "::set-output name=changed::${CHANGED_FILES}" - working-directory: OpenSearch-Dashboards/plugins/${{ env.PLUGIN_NAME }} + with: + format: 'space-delimited' + filters: | + added: .*\.(js|ts|tsx)$ + modified: .*\.(js|ts|tsx)$ - name: Lint Changed Files run: | - CHANGED_FILES="${{ steps.files.outputs.changed }}" + CHANGED_FILES="${{ steps.files.outputs.all }}" + echo "These are the files to be lint: $CHANGED_FILES" if [[ -n "$CHANGED_FILES" ]]; then echo "Linting changed files..." - IFS=$'\n' read -r -a FILES_TO_LINT <<< "$CHANGED_FILES" + IFS=' ' read -r -a FILES_TO_LINT <<< "$CHANGED_FILES" yarn lint "${FILES_TO_LINT[@]}" else echo "No matched files to lint."