From b64618884f69047ef9062994d1003ec5314998a4 Mon Sep 17 00:00:00 2001 From: Cyril Date: Wed, 23 Oct 2024 15:19:01 +0200 Subject: [PATCH] Create autopep8.yml --- .github/workflows/autopep8.yml | 42 ++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 .github/workflows/autopep8.yml diff --git a/.github/workflows/autopep8.yml b/.github/workflows/autopep8.yml new file mode 100644 index 0000000..a49ca11 --- /dev/null +++ b/.github/workflows/autopep8.yml @@ -0,0 +1,42 @@ +name: Autopep8 Linter + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + format: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.x' + + - name: Install autopep8 + run: | + python -m pip install --upgrade pip + pip install autopep8 + + - name: Run autopep8 on Python files + run: | + autopep8 --in-place --aggressive --aggressive --max-line-legth 100 **/*.py + + - name: Check for uncommitted changes + run: | + git config --global user.name "github-actions" + git config --global user.email "github-actions@github.com" + if [[ `git status --porcelain` ]]; then + git add . + git commit -m "Auto-format Python code with autopep8" + git push + else + echo "No formatting changes required."