This repository has been archived by the owner on Dec 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
name: Clang Format Checker and Auto-Fixer | ||
on: | ||
push: | ||
branches: | ||
- '*' | ||
workflow_run: | ||
workflows: ["Clang Format Checker and Auto-Fixer"] | ||
types: | ||
- completed | ||
|
||
jobs: | ||
clang-format-checking: | ||
runs-on: ubuntu-latest | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Install Clang | ||
run: sudo apt-get update && sudo apt-get install -y clang | ||
|
||
- name: Install GitHub CLI | ||
run: | | ||
type -p curl >/dev/null || (sudo apt update && sudo apt install curl -y) | ||
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \ | ||
&& sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg \ | ||
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \ | ||
&& sudo apt update \ | ||
&& sudo apt install gh -y | ||
- name: Check and Auto-Fix Formatting | ||
run: | | ||
find . \( -name "*.h" -or -name "*.c" -or -name "*.cpp" -or -name "*.hpp" -or -name "*.cc" -or -name "*.cxx" -or -name "*.hxx" -or -name "*.inl" -or -name "*.ipp" \) \ | ||
| xargs clang-format -i -style=file | ||
- name: Commit changes (if any) | ||
run: | | ||
git config --local user.email "[email protected]" | ||
git config --local user.name "GitHub Actions" | ||
git diff --exit-code || (git add -A && git commit -m "Auto-fix formatting issues") | ||
# Push changes to the current branch | ||
git push origin HEAD |