Switch to pre-commit/action (#239)

This commit is contained in:
Yuan Tang 2024-10-11 14:09:11 -04:00 committed by GitHub
parent 05282d1234
commit a2b87ed0cb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -22,27 +22,4 @@ jobs:
**/requirements*.txt
.pre-commit-config.yaml
- name: Install pre-commit
run: |
python -m pip install --upgrade pip
pip install pre-commit
- name: Fetch base branch
run: git fetch origin ${{ github.event.pull_request.base.ref }}:refs/remotes/origin/${{ github.event.pull_request.base.ref }}
- name: Fetch head commit from PR
run: git fetch origin pull/${{ github.event.pull_request.number }}/head:pr-${{ github.event.pull_request.number }}
- name: Get changed files
id: changed-files
run: |
git diff --name-only origin/${{ github.event.pull_request.base.ref }} pr-${{ github.event.pull_request.number }} > changed_files.txt
cat changed_files.txt
- name: Run pre-commit
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
- uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd #v3.0.1