Skip to content

Commit

Permalink
add pre-commit gh action
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewm4894 committed Nov 14, 2023
1 parent ebe64f8 commit dfac954
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/pre-commit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: pre-commit

on:
workflow_call:
pull_request_target:

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
# in case of PR, check out the PR's head branch
- uses: actions/checkout@v3
if: github.event_name == 'pull_request_target'
with:
ref: ${{ github.event.pull_request.head.sha }}

# in case of push, check out the main branch
- uses: actions/checkout@v3
if: github.event_name != 'pull_request_target'

- uses: actions/setup-python@v4
with:
python-version: "3.10"
cache: "pip"
cache-dependency-path: "**/requirements*.txt"
- uses: pre-commit/[email protected]
- name: Post PR comment on failure
if: failure() && github.event_name == 'pull_request_target'
uses: peter-evans/create-or-update-comment@v2
with:
issue-number: ${{ github.event.pull_request.number }}
body: |
:x: **pre-commit** failed.
Please run `pre-commit run --all-files` locally and commit the changes.
Find more information in the repository's CONTRIBUTING.md

0 comments on commit dfac954

Please sign in to comment.