File tree Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change 1+ name : ' Format code on pull request'
2+
3+ on :
4+ pull_request :
5+ branches :
6+ - Master
7+ - develop
8+ paths :
9+ - ' **.c'
10+ - ' **.h'
11+
12+ jobs :
13+ clang-format :
14+ name : Format code
15+ runs-on : ubuntu-latest
16+ steps :
17+ - name : Checkout repository
18+ uses : actions/checkout@v4
19+ with :
20+ ref : ${{github.head_ref}}
21+
22+ - name : Install clang-format (formatter tool)
23+ run : sudo apt-get install clang-format
24+
25+ - name : Run clang-format
26+ run : find . -name '*.c' -o -name '*.h' | xargs clang-format -i -style=file
27+
28+ - name : Commit changes
29+ run : |
30+ git config --global user.name 'github-actions[bot]'
31+ git config --global user.email 'github-actions[bot]@users.noreply.github.com'
32+ git add .
33+ git diff-index --quiet HEAD || git commit -m "ci: format code"
34+
35+ - name : Push changes
36+ 37+ with :
38+ branch : ${{ github.head_ref }}
39+ github_token : ${{ secrets.GITHUB_TOKEN }}
You can’t perform that action at this time.
0 commit comments