Skip to content

Commit

Permalink
Update auto_format_python.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
kalcohol authored Feb 6, 2025
1 parent 7e09707 commit f27c69a
Showing 1 changed file with 13 additions and 19 deletions.
32 changes: 13 additions & 19 deletions .github/workflows/auto_format_python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,17 @@ on:
branches:
- main

permissions:
contents: write
pull-requests: write

jobs:
format:
runs-on: ubuntu-latest
permissions:
contents: write

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.head_ref }}

- name: Set up Python
uses: actions/setup-python@v2
Expand All @@ -36,18 +34,14 @@ jobs:
run: |
black .
- name: Check for changes
id: check_changes
run: |
git diff --exit-code || echo "::set-output name=changes::true"
- name: Commit changes
if: steps.check_changes.outputs.changes == 'true'
run: |
git config --local user.name "github-actions[bot]"
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git add .
git commit -m "Format Python code with Black"
git push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
id: commit_changes
uses: stefanzweifel/git-auto-commit-action@v5

- name: "Run if changes have been detected"
if: steps.commit_changes.outputs.changes_detected == 'true'
run: echo "Code formated."

- name: "Run if no changes have been detected"
if: steps.commit_changes.outputs.changes_detected == 'false'
run: echo "No Changes."

0 comments on commit f27c69a

Please sign in to comment.