diff --git a/.github/workflows/autofmt.yml b/.github/workflows/autofmt.yml new file mode 100644 index 0000000..2ee6ca5 --- /dev/null +++ b/.github/workflows/autofmt.yml @@ -0,0 +1,22 @@ +name: autofmt_push +on: [push] +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: nightly + components: rustfmt + - run: cargo fmt -- --check + - name: If needed, commit cargo fmt changes + if: failure() + run: | + cargo fmt + git config --global user.name github-actions + git config --global user.email '${GITHUB_ACTOR}@users.noreply.github.com' + git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY + git commit -am "fixup! Format Rust code with rustfmt" + git push --force origin HEAD:$GITHUB_REF