name: Format Command
on:
repository_dispatch:
types: [fmt-command]
jobs:
fmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
repository: ${{ github.event.client_payload.pull_request.head.repo.full_name }}
ref: ${{ github.event.client_payload.pull_request.head.ref }}
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- name: cargo fmt
id: fmt
run: |
format=$(cargo fmt --check --quiet || echo "true")
echo "format=$format" >> $GITHUB_OUTPUT
- name: Commit to the PR branch
if: steps.fmt.outputs.format == 'true'
run: |
cargo fmt
git config --global user.name 'actions-bot'
git config --global user.email '58130806+actions-bot@users.noreply.github.com'
git commit -am ":art:"
git push
- name: Add reaction
uses: peter-evans/create-or-update-comment@v4
with:
repository: ${{ github.event.client_payload.github.payload.repository.full_name }}
comment-id: ${{ github.event.client_payload.github.payload.comment.id }}
reactions: hooray
reactions-edit-mode: replace