diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index fcff678e..ec8efd55 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -1,11 +1,8 @@ name: Code Formatting on: - push: - branches: [ main, master ] pull_request: branches: [ main, master ] - # Allow manual triggering workflow_dispatch: jobs: @@ -13,15 +10,16 @@ jobs: runs-on: ubuntu-latest permissions: - # Give the default GITHUB_TOKEN write permission to commit and push contents: write + pull-requests: write steps: - name: Checkout repository uses: actions/checkout@v4 with: - fetch-depth: 0 - token: ${{ github.token }} + ref: ${{ github.head_ref }} + fetch-depth: 0 + token: ${{ secrets.GITHUB_TOKEN }} - name: Setup Node.js uses: actions/setup-node@v4 @@ -39,18 +37,12 @@ jobs: run: | git diff --quiet || echo "changes=true" >> $GITHUB_OUTPUT - - name: Configure Git - if: steps.git-check.outputs.changes == 'true' - run: | - git config --global user.email "github-actions[bot]@users.noreply.github.com" - git config --global user.name "github-actions[bot]" - - name: Commit and push changes if: steps.git-check.outputs.changes == 'true' run: | - branch_name=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}} - echo "Current branch: $branch_name" - git add -A - git status - git commit -m "chore: format code" - git push origin HEAD:$branch_name \ No newline at end of file + git config --global user.email "github-actions[bot]@users.noreply.github.com" + git config --global user.name "github-actions[bot]" + + git add -A + git commit -m "chore: format code" + git push \ No newline at end of file