Skip to content

Action to enforce python formatting #4

Action to enforce python formatting

Action to enforce python formatting #4

name: Enforce Python Code Formatting
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
format-check:
runs-on: ubuntu-latest
steps:
- name: Check out the repository
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install black
run: pip install black
- name: Run black
run: black --check .
- name: Post comment on PR if formatting fails
if: failure()
uses: actions/github-script@v3
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `Formatting check failed. Please run \`black .\` to format your code. For more details, please check the 'Checks' tab of this PR.`
});