Skip to content

Merge pull request #333 from robinje/dependabot/pip/requirements/nump… #365

Merge pull request #333 from robinje/dependabot/pip/requirements/nump…

Merge pull request #333 from robinje/dependabot/pip/requirements/nump… #365

name: Python Autoformatting
on:
push:
branches: [develop, qa, prod]
pull_request:
branches: "**"
permissions:
pull-requests: write
contents: write
jobs:
auto-format-python:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install Python Autoformatting Tools
run: |
python -m pip install --upgrade pip
pip install --upgrade wheel
pip install --upgrade isort black ruff
- name: Configure Git
run: |
git fetch -q
git checkout ${{github.head_ref}} --progress
git config --global user.name "Dark Relics Automatic"
git config --global user.email "[email protected]"
git pull
- name: Autoformat Python Files
run: |
isort --atomic --py 312 .
ruff check . --ignore E501 --fix
black . -l 132 -t py312
- name: Check for changes
id: git-check
run: |
git add . -vv
if git diff-index --quiet HEAD; then
echo "changes=false" >> $GITHUB_OUTPUT
else
echo "changes=true" >> $GITHUB_OUTPUT
fi
- name: Commit and push changes
if: steps.git-check.outputs.changes == 'true'
run: |
git commit -m "Apply Python Autoformatting" -vv
git push -vv