Skip to content

Commit 1959539

Browse files
committed
ci: create pr workflow
1 parent 29b1283 commit 1959539

File tree

1 file changed

+38
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)