Create clang_format.yml #1
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
name: clang-format | |
on: [push, pull_request] | |
env: | |
BRANCH_NAME: ${{ github.head_ref || github.ref_name }} | |
jobs: | |
format: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: apply clang format | |
run: | | |
sudo apt install -y clang-format-12 | |
if [ `git rev-parse --verify ci_processing 2>/dev/null` ]; then | |
git branch -D ci_processing | |
fi | |
git config --global user.email "cont-int@github.com" | |
git config --global user.name "continuous integration" | |
# temporary branch | |
git checkout -b ci_processing | |
# apply clang format | |
find . -iname *.h -o -iname *.cpp -o -iname *.hpp | xargs clang-format-12 --style=file -i | |
# push changes (if any) | |
if git commit -a -m "[skip ci] clang format" ; then | |
git push origin ci_processing:${BRANCH_NAME} | |
else | |
echo "No changes, nothing to commit!" | |
fi |