Test format #2
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Auto-format PR | |
| on: | |
| pull_request_target: | |
| types: [opened, synchronize, reopened] | |
| branches: | |
| - main | |
| - release | |
| concurrency: | |
| group: auto-format-${{ github.event.pull_request.number }} | |
| cancel-in-progress: true | |
| jobs: | |
| auto_format: | |
| if: ${{ !contains(github.event.pull_request.labels.*.name, 'skip:ci') }} | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| steps: | |
| - name: Checkout PR branch | |
| uses: actions/checkout@v5 | |
| with: | |
| ref: ${{ github.event.pull_request.head.sha }} | |
| repository: ${{ github.event.pull_request.head.repo.full_name }} | |
| token: ${{ secrets.AUTO_COMMIT_PAT }} | |
| fetch-depth: 0 | |
| - name: Setup Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| components: rustfmt | |
| - name: Run cargo fmt | |
| run: cargo fmt --all | |
| - name: Configure git | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| - name: Check for changes | |
| id: check-changes | |
| run: | | |
| if [ -n "$(git status --porcelain)" ]; then | |
| echo "has_changes=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "has_changes=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Commit and push | |
| if: steps.check-changes.outputs.has_changes == 'true' | |
| run: | | |
| git add -u | |
| git commit -m "Auto-format: cargo fmt --all" | |
| git push origin HEAD:${{ github.event.pull_request.head.ref }} | |
| - name: Comment on PR | |
| if: steps.check-changes.outputs.has_changes == 'true' | |
| uses: marocchino/sticky-pull-request-comment@v2 | |
| with: | |
| number: ${{ github.event.pull_request.number }} | |
| message: | | |
| **Code has been automatically formatted** | |
| The code in this PR has been formatted using `cargo fmt --all`. | |
| Please pull the latest changes before pushing again: | |
| ```bash | |
| git pull origin ${{ github.event.pull_request.head.ref }} | |
| ``` |