Skip to content

Commit

Permalink
164 add code formatting actions (#182)
Browse files Browse the repository at this point in the history
* checking if autoformat action works

* correcting action trigger
  • Loading branch information
K20shores committed Aug 13, 2024
1 parent d9f67f7 commit e06393a
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/pep8_autoformat.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Pep8

on:
push:
branches:
- main

jobs:
autopep8:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: autopep8
uses: peter-evans/autopep8@v2
with:
args: --recursive --in-place --aggressive --aggressive .

- name: Check for changes
id: check-changes
run: git diff --exit-code
continue-on-error: true

- name: Commit and push changes
# a failue of this step means changes were detected
if: steps.check-changes.outcome != 'success'
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "actions@github.com"
git commit -am "Auto-format code using Clang-Format" || echo "No changes to commit"
- name: Push changes to main-autopep8 branch
if: steps.check-changes.outcome != 'success'
run: git push origin HEAD:main-autopep8

- name: Create Pull Request
if: steps.check-changes.outcome != 'success'
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "Auto-format code using autopep8"
title: "Auto-format code by autopep8"
body: "This is an auto-generated PR with fixes by autopep8."
branch: main-autopep8

0 comments on commit e06393a

Please sign in to comment.