Skip to content

Commit

Permalink
Fix lint
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Liang <[email protected]>
  • Loading branch information
RyanL1997 committed Jan 10, 2024
1 parent 1a1957d commit 7536060
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,24 +48,28 @@ 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/[email protected]
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:
token: ${{ secrets.GITHUB_TOKEN }}
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"
yarn lint "${FILES_TO_LINT[@]}"
IFS=' ' read -r -a FILES_TO_LINT <<< "$CHANGED_FILES"
for file in "${FILES_TO_LINT[@]}"; do
if [[ $file == *.js || $file == *.ts || $file == *.tsx ]]; then
yarn lint "$file"
fi
done
else
echo "No matched files to lint."
fi
Expand Down

0 comments on commit 7536060

Please sign in to comment.