Skip to content

Commit

Permalink
Update formatting.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
ProFastCode committed Feb 9, 2024
1 parent 5bd879a commit 26938c4
Showing 1 changed file with 22 additions and 44 deletions.
66 changes: 22 additions & 44 deletions .github/workflows/formatting.yml
Original file line number Diff line number Diff line change
@@ -1,47 +1,25 @@
name: Formatting

on:
push:
branches: [ "main" ]
paths-ignore:
- '**.md'
- '.github/**'
- 'migrations/*'
pull_request:
branches: [ "main" ]
paths-ignore:
- '**.md'
- '.github/**'
- 'migrations/*'

name: black-action
on: [push, pull_request]
jobs:
formatting:
linter_name:
name: runner / black
runs-on: ubuntu-latest

steps:
- name: Checkout 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 .

- name: Commit changes
run: |
git config --global user.email "github-actions@github.com"
git config --global user.name "GitHub Actions"
git add .
git diff-index --quiet HEAD || git commit -m "Auto-format code with Black"
git push
- name: Check git status after commit
run: git status



- uses: actions/checkout@v2
- name: Check files using the black formatter
uses: rickstaa/action-black@v1
id: action_black
with:
black_args: "."
- name: Create Pull Request
if: steps.action_black.outputs.is_formatted == 'true'
uses: peter-evans/create-pull-request@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
title: "Format Python code with psf/black push"
commit-message: ":art: Format Python code with psf/black"
body: |
There appear to be some python formatting errors in ${{ github.sha }}. This pull request
uses the [psf/black](https://github.com/psf/black) formatter to fix these issues.
base: ${{ github.head_ref }} # Creates pull request onto pull request or commit branch
branch: actions/black

0 comments on commit 26938c4

Please sign in to comment.