-
Notifications
You must be signed in to change notification settings - Fork 8
56 lines (47 loc) · 1.59 KB
/
lint-js.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
name: Lint JS
on:
# Run on pushes to select branches and on all pull requests.
push:
branches:
- main
- develop
- trunk
- 'feature/**'
- 'release/**'
- 'hotfix/[0-9]+.[0-9]+*'
pull_request:
# Allow manually triggering the workflow.
workflow_dispatch:
# Cancels all previous workflow runs for the same branch that have not yet completed.
concurrency:
# The concurrency group contains the workflow name and the branch name.
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
lint:
runs-on: ubuntu-latest
name: "Lint: JS"
steps:
- name: Checkout code
uses: actions/checkout@v3
# Cache the Node.js modules to speed up the workflow.
- name: Cache Node.js modules
uses: actions/cache@v2
with:
path: node_modules
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
# The lint stage doesn't run the unit tests or use code style, so no need for PHPUnit, WPCS or phpcompatibility.
- name: 'Install NPM packages'
run: npm install --ignore-scripts
# Only run ESLint on changed JavaScript files.
- name: 'Get changed JavaScript files'
id: jsfiles
run: |
echo "JS_FILES<<EOF" >> $GITHUB_ENV
git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep '\.js$' || echo ""
echo "EOF" >> $GITHUB_ENV
- name: 'Run ESLint'
if: env.JS_FILES != ''
run: npm run lint:js -- ${{ env.JS_FILES }}