-
Notifications
You must be signed in to change notification settings - Fork 0
51 lines (42 loc) · 1.21 KB
/
Copy pathpre-commit.yml
File metadata and controls
51 lines (42 loc) · 1.21 KB
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
name: Pre-commit
permissions:
contents: read
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.12'
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version: '24'
cache: 'npm'
- name: Install Node.js dependencies
run: npm ci
- name: Cache pre-commit environments
uses: actions/cache@v5
with:
path: ~/.cache/pre-commit
key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
restore-keys: |
pre-commit-
- name: Install pre-commit
run: pip install pre-commit
- name: Run pre-commit on all files (main branch)
if: github.ref == 'refs/heads/main'
run: pre-commit run --all-files
- name: Run pre-commit on changed files (PRs)
if: github.event_name == 'pull_request'
run: pre-commit run --from-ref ${{ github.event.pull_request.base.sha }} --to-ref HEAD