-
Notifications
You must be signed in to change notification settings - Fork 0
45 lines (36 loc) · 1.33 KB
/
clang-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
name: Clang-Format
on: [push]
jobs:
clang-format:
name: Clang-Format
runs-on: ubuntu-latest
permissions:
contents: write
environment: ${{ github.actor }}_environment
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
persist-credentials: false
fetch-depth: 0
- name: Set up Clang-Format
run: sudo apt-get install -y clang-format
- name: Format source code
run: clang-format -i game/**/*.cpp game/**/*.hpp --ferror-limit=0 --style file:.clang-format --verbose
- name: Format tests
run: clang-format -i tests/**/*.cpp tests/**/*.hpp --ferror-limit=0 --style file:.clang-format --verbose
- name: Check for modifications
id: check_modifications
run: |
git diff --exit-code > /dev/null || echo "modified=true" >> $GITHUB_ENV
- name: Commit and push changes
if: env.modified == 'true'
run: |
git config --global user.email "${{ github.event.commits[0].author.email }}"
git config --global user.name "${{ github.event.commits[0].author.name }}"
git commit -a -m "Autoformat code"
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}