-
Notifications
You must be signed in to change notification settings - Fork 0
39 lines (33 loc) · 1.17 KB
/
format-code-on-pr.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
name: 'Format code on pull request'
on:
pull_request:
branches:
- Master
- develop
paths:
- '**.c'
- '**.h'
jobs:
clang-format:
name: Format code
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{github.head_ref}}
- name: Install clang-format (formatter tool)
run: sudo apt-get install clang-format
- name: Run clang-format
run: find . -name '*.c' -o -name '*.h' | xargs clang-format -i -style=file
- name: Commit changes
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git add .
git diff-index --quiet HEAD || git commit -m "ci: format code"
- name: Push changes
uses: ad-m/[email protected]
with:
branch: ${{ github.head_ref }}
github_token: ${{ secrets.GITHUB_TOKEN }}