chore(deps): update dependency eslint-config-sanity to v7 (#5100) #5479
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
name: Lint changed files | |
on: | |
# Build on pushes branches that have a PR (including drafts) | |
pull_request: | |
# Build on commits pushed to branches without a PR if it's in the allowlist | |
push: | |
branches: [next] | |
jobs: | |
lint: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Cache node modules | |
id: cache-node-modules | |
uses: actions/cache@v3 | |
env: | |
cache-name: cache-node-modules | |
with: | |
path: '**/node_modules' | |
key: ${{ runner.os }}-modules-${{ env.cache-name }}-${{ hashFiles('**/yarn.lock') }} | |
restore-keys: | | |
${{ runner.os }}-modules-${{ env.cache-name }}- | |
${{ runner.os }}-modules- | |
${{ runner.os }}- | |
- name: Install project dependencies | |
if: steps.cache-node-modules.outputs.cache-hit != 'true' | |
run: yarn install --frozen-lockfile | |
- name: Lint changed files | |
id: listChangedFiles | |
run: | | |
# Is this a pull request? | |
if [ $GITHUB_BASE_REF ]; then | |
# If it is - compare against the base branch | |
# $GITHUB_BASE_REF is the branch you're merging *to* | |
git fetch origin $GITHUB_BASE_REF --depth=1 | |
COMPARE_WITH=origin/$GITHUB_BASE_REF | |
CHANGED_FILES=$( git diff --name-only $COMPARE_WITH $GITHUB_SHA --diff-filter ACMRTUXB ) | |
printf "\nThese files have changed between $COMPARE_WITH and $GITHUB_SHA:\n$CHANGED_FILES\n" | |
else | |
# If not it's a commit, check the files changed in this commit | |
git fetch origin $GITHUB_SHA --depth=2 | |
CHANGED_FILES=$( git diff-tree --no-commit-id --name-only --diff-filter ACMRTUXB -r $GITHUB_SHA ) | |
printf "\nThese files have changed in $GITHUB_SHA:\n$CHANGED_FILES\n" | |
fi | |
# Don't include files like LICENSE and css files | |
CHANGED_JS_FILES=$(echo "$CHANGED_FILES" | sed -e '/^.\+\(mjs\|tsx\|jsx\|js\|ts\)$/!d') | |
for FILE_NAME in $CHANGED_JS_FILES | |
do | |
yarn eslint $FILE_NAME | |
done |