-
Notifications
You must be signed in to change notification settings - Fork 16
47 lines (39 loc) · 1.3 KB
/
pre-commit.yml
File metadata and controls
47 lines (39 loc) · 1.3 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
name: pre-commit
on:
pull_request:
push:
branches: [master]
jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
# Need full history so the diff range below can resolve the
# base/before SHA against actual commits, not just HEAD.
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install pre-commit
run: pip install pre-commit
- name: Install image tooling (jpegoptim, oxipng, svgo)
run: |
sudo apt-get update
sudo apt-get install -y jpegoptim
cargo install oxipng --locked
npm install -g svgo
- name: Run pre-commit on the PR's changed files
if: github.event_name == 'pull_request'
run: |
pre-commit run --show-diff-on-failure \
--from-ref ${{ github.event.pull_request.base.sha }} \
--to-ref ${{ github.event.pull_request.head.sha }}
- name: Run pre-commit on the push's changed files
if: github.event_name == 'push'
run: |
pre-commit run --show-diff-on-failure \
--from-ref ${{ github.event.before }} \
--to-ref ${{ github.sha }}