File tree 1 file changed +18
-29
lines changed
1 file changed +18
-29
lines changed Original file line number Diff line number Diff line change 5
5
branches : [master]
6
6
7
7
jobs :
8
- build :
8
+ lint :
9
9
name : Lint updated JavaScript files with ESLint
10
10
11
- runs-on : ubuntu-20.04
11
+ runs-on : ubuntu-latest
12
12
13
13
steps :
14
14
- name : Checkout code
15
- uses : actions/checkout@v3
15
+ uses : actions/checkout@v4
16
16
with :
17
17
fetch-depth : 0
18
18
ref : ${{ github.event.pull_request.head.sha }}
19
19
20
- - name : Use Node.js
21
- uses : actions/setup-node@v1
20
+ - name : Set up Node.js
21
+ uses : actions/setup-node@v4
22
22
with :
23
- node-version : 12 .x
23
+ node-version : 20 .x
24
24
25
- - name : Get changed files
26
- id : getfile
25
+ - name : Get changed JavaScript files
26
+ id : get_files
27
27
run : |
28
- CHANGED_FILES="$(git diff --name-only ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }} | xargs)"
29
- export CHANGED_FILES # the export command will fail if the inner shell expansion failed
30
- echo "files=$CHANGED_FILES" >> $GITHUB_OUTPUT
28
+ CHANGED_FILES=$(git diff --name-only ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }} -- '*.js')
29
+ echo "files<<EOF" >> $GITHUB_ENV
30
+ echo "$CHANGED_FILES" >> $GITHUB_ENV
31
+ echo "EOF" >> $GITHUB_ENV
31
32
32
- - name : Install ESLint
33
+ - name : Install dependencies
33
34
run : npm install eslint
34
35
35
- - name : Lint changed files using ESLint
36
+ - name : Run ESLint on changed files
37
+ if : env.files != ''
36
38
run : |
37
- for i in ${{ steps.getfile.outputs.files }}
38
- do
39
- if [[ "$i" == "D" ]]
40
- then
41
- ignore=1
42
- elif [[ ( "$i" == "M" ) || ( "$i" == "A" ) || ( "$i" == "R" ) || ( "$i" == "C" ) || ( "$i" == "U" ) ]]
43
- then
44
- ignore=0
45
- fi
46
- echo "file $i $ignore"
47
- if [[ "$i" == *".js" && $ignore == 0 ]]
48
- then
49
- echo "linting $i"
50
- npx eslint $i
51
- fi
52
- done
39
+ echo "Linting the following files:"
40
+ echo "$files"
41
+ echo "$files" | xargs npx eslint
You can’t perform that action at this time.
0 commit comments