action: clang format

This commit is contained in:
YiFang Xiao 2023-05-27 22:02:10 +08:00 committed by xiaoyifang
parent ce08f5520a
commit 854efbc517

View file

@ -34,9 +34,11 @@ jobs:
sudo apt-get update
sudo apt-get install -y clang-format
git-clang-format --style=file HEAD^
git diff > clang-format.patch
# remove file if empty
[ -s clang-format.patch ] || rm clang-format.patch
echo 'The following is clang format diff if has any.' > /home/runner/work/clang-format.patch
echo '```cpp' >> /home/runner/work/clang-format.patch
git diff >> /home/runner/work/clang-format.patch
echo '```' >> /home/runner/work/clang-format.patch
- uses: EndBug/add-and-commit@v9
if: ${{ github.event.pull_request.head.repo.full_name == 'xiaoyifang/goldendict-ng' }}
@ -44,20 +46,8 @@ jobs:
default_author: github_actor
message: 🎨 apply clang-format changes
- name: Check file existence
id: check_files
uses: andstor/file-existence-action@v2
with:
files: "clang-format.patch"
- name: File not exists
if: steps.check_files.outputs.files_exists != 'true'
run: echo the file is not existed
- name: PR comment with file
uses: thollander/actions-comment-pull-request@v2
if: steps.check_files.outputs.files_exists == 'true'
with:
filePath: /home/runner/work/goldendict-ng/goldendict-ng/clang-format.patch
filePath: /home/runner/work/clang-format.patch
pr_number: ${{ github.event.number }}