Skip to content

Commit

Permalink
Update code_formatter.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
blaisewf authored Sep 14, 2024
1 parent 0e3481b commit a2c019b
Showing 1 changed file with 17 additions and 18 deletions.
35 changes: 17 additions & 18 deletions .github/workflows/code_formatter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,49 +4,48 @@ on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
format:
push_format:
runs-on: ubuntu-latest

permissions:
contents: write
pull-requests: write

steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref || github.ref_name }}
ref: ${{github.ref_name}}

- name: Set up Python
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: "3.x"
python-version: ${{ matrix.python-version }}

- name: Install Black
run: pip install "black[jupyter]"

- name: Run Black
# run: black $(git ls-files '*.py')
run: black . --exclude=".*\.ipynb$"

- name: Commit changes
if: github.event_name == 'pull_request'
- name: Commit Back
continue-on-error: true
id: commitback
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git commit -am "chore(format): run black" || echo "No changes to commit"
git push
git add --all
git commit -m "chore(format): run black on ${{github.ref_name}}"
- name: Create Pull Request
if: github.event_name == 'push'
if: steps.commitback.outcome == 'success'
continue-on-error: true
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "chore(format): run black"
title: "chore(format): run black"
body: |
This is an auto-generated PR with formatting changes from Black.
branch: format-${{ github.sha }}
delete-branch: true
body: "Automatically apply code formatter change"
title: "chore(format): run black on ${{github.ref_name}}"
commit-message: "chore(format): run black on ${{github.ref_name}}"
branch: formatter/${{github.ref_name}}

0 comments on commit a2c019b

Please sign in to comment.