This repository has been archived by the owner on Dec 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
40 lines (34 loc) · 1.63 KB
/
ClangFormat.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
name: Clang Format Checker and Auto-Fixer
on:
pull_request:
branches:
- main
jobs:
clang-format-checking:
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v2
- name: Install Clang
run: sudo apt-get update && sudo apt-get install -y clang
- name: Install GitHub CLI
run: |
type -p curl >/dev/null || (sudo apt update && sudo apt install curl -y)
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \
&& sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
&& sudo apt update \
&& sudo apt install gh -y
- name: Check and Auto-Fix Formatting
run: |
find . \( -name "*.h" -or -name "*.c" -or -name "*.cpp" -or -name "*.hpp" -or -name "*.cc" -or -name "*.cxx" -or -name "*.hxx" -or -name "*.inl" -or -name "*.ipp" \) \
| xargs clang-format -i -style=file
- name: Commit changes (if any)
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Actions"
git diff --exit-code || (git add -A && git commit -m "Auto-fix formatting issues")
- name: Push changes to the pull request branch
run: |
git push origin HEAD:$GITHUB_HEAD_REF