-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Ryan Liang <[email protected]>
- Loading branch information
Showing
1 changed file
with
16 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|