diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml new file mode 100644 index 000000000..795266ae1 --- /dev/null +++ b/.github/workflows/pre-commit.yml @@ -0,0 +1,34 @@ +name: pre-commit + +on: + # Triggers the workflow on ALL push or pull request events + # except for the `gh-pages`` branch + push: + branches-ignore: + - gh-pages + pull_request: + branches-ignore: + - gh-pages + +permissions: + contents: write + +jobs: + pre-commit: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: 3.x + + - uses: pre-commit/action@v3.0.1 + + - name: Commit changes + if: ${{ !cancelled() && failure() }} + shell: bash + run: | + git config --local user.name "pre-commit-ci[bot]" + git config --local user.email "66853113+pre-commit-ci[bot]@users.noreply.github.com" + git commit -m "[pre-commit.ci] auto-fixes from pre-commit hooks" -a + git push origin HEAD:${{ github.head_ref || github.ref_name }} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 1bc8e51c5..e0573851a 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -42,4 +42,4 @@ jobs: ghp-import site --push - uses: actions/upload-artifact@v4.4.0 with: - path: './site' \ No newline at end of file + path: './site' diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 000000000..03b9eb100 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,18 @@ +ci: + autofix_commit_msg: '[pre-commit.ci] auto-fixes from pre-commit hooks' + +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.6.0 + hooks: + - id: check-added-large-files + args: + - --maxkb=10000 + - id: check-merge-conflict + - id: mixed-line-ending + args: + - --fix=lf + - id: detect-private-key + - id: end-of-file-fixer + - id: forbid-new-submodules + - id: trailing-whitespace