Add workflow to format code automatically
This commit is contained in:
parent
0bc769e702
commit
6e8ebde058
22
.github/workflows/autofmt.yml
vendored
Normal file
22
.github/workflows/autofmt.yml
vendored
Normal file
|
@ -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
|
Loading…
Reference in a new issue