-
Notifications
You must be signed in to change notification settings - Fork 0
58 lines (49 loc) · 1.64 KB
/
format.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
name: Code Formatting
on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:
jobs:
format:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Install clang-format and dos2unix
run: |
sudo apt-get update
sudo apt-get install -y clang-format dos2unix
- name: Get Current Date
id: date
run: echo "CURRENT_DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
- name: Run dos2unix on All Files
run: find . -type f -exec dos2unix {} \;
- name: Commit dos2unix Changes
run: |
git config --global user.name "${{ github.actor }}"
git config --global user.email "${{ github.actor }}@users.noreply.github.com"
git add .
if git diff --staged --quiet; then
echo "No changes after dos2unix, skipping commit."
else
git commit -m "Applied dos2unix automatically (${{ env.CURRENT_DATE }})"
git push
fi
- name: Run clang-format on CPP Files
run: |
find . -iname "*.cpp" -exec clang-format -i --style=file {} \;
- name: Commit clang-format Changes
run: |
git config --global user.name "${{ github.actor }}"
git config --global user.email "${{ github.actor }}@users.noreply.github.com"
git add .
if git diff --staged --quiet; then
echo "No changes after clang-format, skipping commit."
else
git commit -m "Applied clang-format automatically (${{ env.CURRENT_DATE }})"
git push
fi