Allow running clang-format
on C/C++ sources using Github actions. A .clang-format
file is required.
BRANCH
(environment variable) branch where the formatter will be run.exclude-regex
can be used to avoid formatting certain folders.
This action will run this action on every push, formatting all C/C++ files except the ones from lib/
folder):
.github/workflows/formatter.yml
:
on: push
name: clang-format Code Formatter
jobs:
lint:
name: clang-format Code Formatter
runs-on: ubuntu-latest
steps:
- name: Clang Code Formatter
uses: roby2014/clang-format-action@v1.0
env:
BRANCH: 'main'
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
exclude-regex: 'lib/' #optional