From f27c69a0522de47d0319494eb6db99c3dfa0eef8 Mon Sep 17 00:00:00 2001 From: kalcohol <314377460@qq.com> Date: Thu, 6 Feb 2025 21:22:13 +0800 Subject: [PATCH] Update auto_format_python.yml --- .github/workflows/auto_format_python.yml | 32 ++++++++++-------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/.github/workflows/auto_format_python.yml b/.github/workflows/auto_format_python.yml index 4e7ef0c..a8ec134 100644 --- a/.github/workflows/auto_format_python.yml +++ b/.github/workflows/auto_format_python.yml @@ -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 @@ -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."