update github action (clang format) (#3489)

This commit is contained in:
fish9167
2021-04-29 11:12:28 +08:00
committed by GitHub
parent 894225682d
commit f147841c54
2 changed files with 22 additions and 10 deletions
+2
View File
@@ -0,0 +1,2 @@
# ignore third_party code from clang-format checks
./cocos/bindings/auto/*
+20 -10
View File
@@ -2,29 +2,38 @@ name: Apply Clang Format
#on: [push, pull_request]
on:
pull_request:
pull_request_target:
types: [closed]
jobs:
Clang-Format:
if: github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true
if: github.event_name == 'pull_request_target' && github.event.action == 'closed' && github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
token: ${{secrets.GITHUB_TOKEN }}
token: ${{ github.token }}
ref: ${{ github.head_ref }}
- name: install clang-format
- id: get_change_files
uses: fish9167/file-changes-action@v1.2.3
with:
output: ' '
fileOutput: ' '
- name: get change files
run: |
sudo apt-get install clang-format git
- name: apply clang-format
run: |
SRC=$(git ls-tree --full-tree -r HEAD | grep -e "\.\(c\|h\|hpp\|cpp\|cxx\)\$" | cut -f 2)
clang-format -style=file -i $SRC
cat $HOME/files.txt
mv $HOME/files.txt ${{github.workspace}}/files.txt
- uses: fish9167/clang-format-lint-action@master
with:
exclude: .clang-format-ignore
extensions: 'c,h,hpp,cpp,cxx'
style: file
inplace: True
- uses: fish9167/git-auto-commit-action@v4
with:
commit_message: Apply clang-format
@@ -32,3 +41,4 @@ jobs:
commit_user_email: cocos-robot@cocos.com
commit_author: cocos-robot <cocos-robot@cocos.com>
push_options: --force