Skip to content

TEST for format and PR #13

TEST for format and PR

TEST for format and PR #13

Workflow file for this run

name: Black
on:
push:
branches:
- main
- master
- 'feature/*'
pull_request:
branches:
- main
- master
- 'feature/*'
jobs:
black:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Cache Black
uses: actions/cache@v3
with:
path: ~/.cache/pypoetry
key: ${{ runner.os }}-black-${{ hashFiles('**/pyproject.toml') }}
restore-keys: |
${{ runner.os }}-black-
- name: Install Black
run: |
python -m pip install --upgrade pip
pip install black
- name: Format Code with Black
run: |
black . # Format all Python files in the repo
- name: Commit Changes
run: |
if [[ `git status --porcelain` ]]; then
git checkout -b auto-format-black-${{ github.run_id }}
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git add .
git commit -m "chore: auto-format code with Black"
git push --set-upstream https://x-access-token:${{ secrets.PAT_TOKEN }}@github.com/${{ github.repository }}.git auto-format-black-${{ github.run_id }}
fi
- name: Push Branch
run: |
git push origin auto-format-black-${{ github.run_id }}
- name: Create Pull Request
uses: peter-evans/create-pull-request@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
title: "chore: auto-format code with Black"
body: "This PR auto-formats the codebase using Black."
branch: auto-format-black-${{ github.run_id }} # This is the branch we pushed
base: master # Target branch for the PR