File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : Auto Format C++ (Google Style)
2+
3+ on :
4+ push :
5+ branches : [ main ]
6+ paths :
7+ - " **/*.cpp"
8+ - " **/*.h"
9+ - " **/*.hpp"
10+ - " .clang-format"
11+
12+ jobs :
13+ format :
14+ runs-on : ubuntu-latest
15+
16+ steps :
17+ - name : Checkout repository
18+ uses : actions/checkout@v4
19+ with :
20+ fetch-depth : 0 # required for pushing commits
21+
22+ - name : Install clang-format
23+ run : |
24+ sudo apt-get update
25+ sudo apt-get install -y clang-format
26+
27+ - name : Create Google style config if missing
28+ run : |
29+ if [ ! -f .clang-format ]; then
30+ echo "BasedOnStyle: Google" > .clang-format
31+ echo "ColumnLimit: 80" >> .clang-format
32+ fi
33+
34+ - name : Run clang-format on C++ files
35+ run : |
36+ find . -regex '.*\.\(cpp\|hpp\|h\)$' -exec clang-format -i {} \;
37+
38+ - name : Auto-commit formatted files
39+ uses : stefanzweifel/git-auto-commit-action@v5
40+ with :
41+ commit_message : " style: auto-format C++ sources (Google, 80 cols)"
42+ branch : ${{ github.ref }}
43+ file_pattern : " *.cpp *.h *.hpp"
You can’t perform that action at this time.
0 commit comments