autoformat bot in CI #9
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: PR Pre-Commit Bot | |
| env: | |
| JULIA_NUM_THREADS: 2 | |
| concurrency: | |
| # group by workflow and ref; the last slightly strange component ensures that for pull | |
| # requests, we limit to 1 concurrent job, but for the master branch we don't | |
| group: ${{ github.workflow }}-${{ github.ref }}-${{ (github.ref != 'refs/heads/master' && github.ref != 'refs/heads/main') || github.run_number }} | |
| # Cancel intermediate builds, but only if it is a pull request build. | |
| cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }} | |
| on: | |
| pull_request: | |
| branches: ["master", "main"] | |
| jobs: | |
| pre-commit: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v3 | |
| with: | |
| persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal token | |
| fetch-depth: 0 # otherwise, you will failed to push refs to dest repo | |
| - name: Setup Julia | |
| uses: julia-actions/setup-julia@v2 | |
| with: | |
| version: '1' | |
| - uses: julia-actions/cache@v2 | |
| - name: Setup JuliaFormatter | |
| run: | | |
| julia -e ' | |
| using Pkg | |
| Pkg.add(name="JuliaFormatter", version="1.0.62")' | |
| - name: Setup Python | |
| uses: actions/setup-python@v3 | |
| - name: Run pre-commit | |
| uses: pre-commit/[email protected] | |
| continue-on-error: true | |
| - name: Commit files | |
| run: | | |
| git config --local user.email "[email protected]" | |
| git config --local user.name "PR Pre-Commit Bot" | |
| git diff-index --quiet HEAD || git commit -m "add bot commits" -a | |
| - name: Push changes | |
| uses: ad-m/[email protected] | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| branch: ${{ github.head_ref }} |