Update code_formatter.yml #6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Code Formatter | |
on: | |
push: | |
branches: | |
- # main | |
jobs: | |
push_format: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
pull-requests: write | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.ref_name }} | |
- name: Setup Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.10' | |
- name: Installing Dependencies | |
run: pip install black isort autoflake | |
- name: Run autoflake | |
run: autoflake --in-place --recursive . | |
- name: Run isort | |
run: isort . | |
- name: Run Black | |
run: black . | |
- name: Check for changes | |
id: changes | |
run: | | |
if [ -n "$(git status --porcelain)" ]; then | |
echo "::set-output name=has_changes::true" | |
else | |
echo "::set-output name=has_changes::false" | |
fi | |
- name: Commit changes | |
if: steps.changes.outputs.has_changes == 'true' | |
run: | | |
git config --local user.email "github-actions[bot]@users.noreply.github.com" | |
git config --local user.name "github-actions[bot]" | |
git add --all | |
git commit -m "Automatic code formatting." | |
- name: Create Pull Request | |
if: steps.changes.outputs.has_changes == 'true' | |
uses: peter-evans/create-pull-request@v5 | |
with: | |
delete-branch: true | |
body: "Automatic code formatting." | |
title: "Automatic code formatting." | |
commit-message: "Automatic code formatting." | |
branch: formatter/main |