goldendict-ng/.github/workflows/auto clang format.yml
2023-05-27 22:28:28 +08:00

54 lines
1.7 KiB
YAML

name: "auto clang-format code"
on:
pull_request:
branches:
# - dev
# - master
- staged
paths-ignore:
- "docs/**"
# - ".github/**"
- "howto/**"
- "*.md"
- "locale/**"
jobs:
format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3.5.2
with:
# check out HEAD on the branch
ref: ${{ github.head_ref }}
repository: ${{github.event.pull_request.head.repo.full_name}}
# make sure the parent commit is grabbed as well, because
# that's what will get formatted (i.e. the most recent commit)
fetch-depth: 2
# format the latest commit
- name: ubuntu install clang-format
shell: bash
run: |
sudo apt-get install git lsb-release wget software-properties-common
wget -qO - https://apt.llvm.org/llvm.sh| sudo bash
sudo apt-get update
sudo apt-get install -y clang-format
git-clang-format --style=file HEAD^
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' }}
with:
default_author: github_actor
message: 🎨 apply clang-format changes
- name: PR comment with file
uses: thollander/actions-comment-pull-request@v2
with:
filePath: /home/runner/work/clang-format.patch
pr_number: ${{ github.event.number }}