Skip to content

Commit

Permalink
Create black_manual.yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
montyly authored Oct 2, 2024
1 parent 7f3b4ad commit 429c304
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/black_manual.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Manual Black formatting

on:
workflow_dispatch: # This allows you to manually trigger the workflow

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
format-code:
runs-on: ubuntu-latest
if: github.actor == 'montyly' || github.actor == 'smonicas' # only Josselin or Simone can trigger this
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }} # Checkout the branch of the PR

- name: Set up Python
uses: actions/checkout@v4
with:
python-version: '3.x'

- name: Install Black
run: pip install .[dev]

- name: Run Black and auto-format code
run: black .

- name: Commit and push changes if formatting occurred
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Actions"
git add .
git diff-index --quiet HEAD || git commit -m "Auto format code with Black"
git push origin ${{ github.head_ref }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit 429c304

Please sign in to comment.