feat(ci): autoformat commits #4
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
| # This workflow runs on every push and automatically applies formatting using mise format | |
| name: Auto-format code | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| on: | |
| push: | |
| branches: | |
| - "**" | |
| jobs: | |
| format: | |
| runs-on: ubuntu-24.04-arm | |
| # Only run on the main repo, skip forks | |
| # Skip if commit is already from this auto-format workflow to avoid infinite loops | |
| if: github.repository == 'ChainSafe/forest' && !contains(github.event.head_commit.message, '[LeshyBot] Apply automatic formatting') | |
| steps: | |
| - uses: actions/create-github-app-token@v2 | |
| id: generate-token | |
| with: | |
| app-id: ${{ secrets.LESHY_APP_ID }} | |
| private-key: ${{ secrets.LESHY_APP_PRIVATE_KEY }} | |
| - uses: actions/checkout@v6 | |
| with: | |
| token: ${{ steps.generate-token.outputs.token }} | |
| fetch-depth: 0 | |
| - uses: jdx/mise-action@v3 | |
| - run: mise install-lint-tools | |
| - run: mise format | |
| - 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 formatting changes | |
| if: steps.check-changes.outputs.has_changes == 'true' | |
| run: | | |
| git config user.name "LeshyBot" | |
| git add . | |
| git commit -m "[LeshyBot] Apply automatic formatting" | |
| git push |