Initial commit #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Pre-commit | |
on: | |
pull_request: | |
push: | |
branches: [main] | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
pre-commit: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.12' | |
cache: pip | |
cache-dependency-path: | | |
**/pyproject.toml | |
.pre-commit-config.yaml | |
- uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1 | |
env: | |
SKIP: no-commit-to-branch | |
- name: Verify if there are any diff files after pre-commit | |
run: | | |
git diff --exit-code || (echo "There are uncommitted changes, run pre-commit locally and commit again" && exit 1) | |
- name: Verify if there are any new files after pre-commit | |
run: | | |
unstaged_files=$(git ls-files --others --exclude-standard) | |
if [ -n "$unstaged_files" ]; then | |
echo "There are uncommitted new files, run pre-commit locally and commit again" | |
echo "$unstaged_files" | |
exit 1 | |
fi |