Keeps your repo tidy by running clang-format on every PR.
Add the following to .github/workflows/pr.yaml:
name: PRon:
pull_request:
jobs:
checks:
runs-on: ubuntu-latestname: checkssteps:
- name: clang-formatid: clang-formatuses: tinybeachthor/gitbot-format@releases/v1with:
repo-token: ${{ secrets.GITHUB_TOKEN }}config-path: '.clang-format'Enjoy automatic clang-format linting.
Optionally, to allow formatting, add .github/workflows/comment.yaml:
name: Commenton:
pull_request:
types:
- opened
- editedissue_comment:
types:
- created
- editedjobs:
format:
runs-on: ubuntu-latestname: Formatenv:
TAKE_ACTION: truesteps:
- name: Check for trigger worduses: khan/pull-request-comment-trigger@1.0.0id: triggerwith:
trigger: '/format'reaction: hoorayenv:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: clang-formatid: clang-formatuses: tinybeachthor/gitbot-format@releases/v1with:
repo-token: ${{ secrets.GITHUB_TOKEN }}config-path: '.clang-format'if: steps.trigger.outputs.triggered == 'true'This will trigger auto-formatting whenever you comment /format in a PR.
Just a regular .clang-format file in the root of the repo.
Checks on the default branch first, PR branch second, and defaults
to -style=Google if none found.
Only looks on files changed in a PR, so that it does not introduce extra changes from beyond the scope of the PR.
Why prefer stylefile from the default branch to feature branch stylefile?
Since the goal is to keep the format of the whole codebase consistent, preferring the default branch stylefile will enforce the same style on all feature branches and make changes to the stylefile propagate instantly (no need to rebase every feature branch)
ISC © 2020 Martin Toman toman.martin@live.com