name: Check ClangFormat

on:
  push:
    branches:
      - main
      - '[0-9]+.x'
  pull_request:
    branches:
      - main
      - '[0-9]+.x'
  workflow_dispatch:

jobs:
  check_clang_format:
    runs-on: ubuntu-20-large
    steps:
      - uses: actions/checkout@v2
      - name: Run ClangFormat
        run: find . | grep -E '\.(c|h|cc)$' | grep -E -v '^./(third_party|cmake)' | xargs clang-format -i
      - name: Check for differences
        run: git diff --exit-code
