-
Notifications
You must be signed in to change notification settings - Fork 145
49 lines (41 loc) · 1.36 KB
/
lint.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
name: Lint and Format Check
on:
pull_request:
push:
branches:
- main
workflow_dispatch: {}
jobs:
lint-and-format:
if: github.event.pull_request.labels.*.name != 'skip-lint'
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
- name: Install Dependencies
run: npm ci
- name: Get Changed Files (Compare with Main)
id: get_changed_files
run: |
git fetch origin main --depth=1
CHANGED_FILES=$(git diff --name-only origin/main | grep -E '\.(ts|js)$' || true)
if [ -n "$CHANGED_FILES" ]; then
echo "Files changed:"
echo "$CHANGED_FILES"
echo "$CHANGED_FILES" > changed_files.txt
echo "files_changed=true" >> $GITHUB_OUTPUT
else
echo "No relevant files changed."
echo "files_changed=false" >> $GITHUB_OUTPUT
fi
- name: Run Prettier Check
if: steps.get_changed_files.outputs.files_changed == 'true'
run: xargs npm run format:check < changed_files.txt
- name: Run Oxlint
if: steps.get_changed_files.outputs.files_changed == 'true'
run: xargs npm run lint:strict < changed_files.txt