Skip to content

Commit

Permalink
ci: Only run pre-commit on diff instead of all files
Browse files Browse the repository at this point in the history
Signed-off-by: Russell Bryant <rbryant@redhat.com>
  • Loading branch information
russellb committed Oct 3, 2024
1 parent f85b055 commit 76a55b6
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Pre-commit

on: [push, pull_request]
on: [pull_request]

jobs:
pre-commit:
Expand All @@ -24,5 +24,19 @@ jobs:
python -m pip install --upgrade pip
pip install pre-commit
- name: git fetch
run: git fetch --all

- name: Get changed files
id: changed-files
run: |
git diff --name-only origin/${{ github.event.pull_request.base.ref }} ${{ github.event.pull_request.head.sha }} > changed_files.txt
cat changed_files.txt
- name: Run pre-commit
run: pre-commit run --all-files
run: |
if [ -s changed_files.txt ]; then
pre-commit run --files $(cat changed_files.txt | tr '\n' ' ')
else
echo "No changed files to run pre-commit on."
fi

0 comments on commit 76a55b6

Please sign in to comment.