Skip to content
This repository has been archived by the owner on Dec 2, 2024. It is now read-only.

Commit

Permalink
Create ClangFormat.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
Arteiii authored Feb 12, 2024
1 parent e34f012 commit b5e1cf5
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/ClangFormat.yml
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

0 comments on commit b5e1cf5

Please sign in to comment.