refactor(.gitignore): 更新 .gitignore 文件,忽略所有 .sh 脚本 #246
This file contains hidden or 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: Format C++ Code | |
| on: | |
| push: | |
| pull_request: | |
| types: | |
| - opened | |
| - synchronize | |
| - reopened | |
| jobs: | |
| format: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| # 关键:获取完整的 git 历史和分支信息 | |
| fetch-depth: 0 | |
| # 确保有推送权限 | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| # 检出 PR 的 head 分支,而不是 merge commit | |
| ref: ${{ github.head_ref }} | |
| - name: Install clang-format | |
| run: sudo apt-get update && sudo apt-get install -y clang-format | |
| - name: Run clang-format | |
| run: find src -name "*.h" -o -name "*.hpp" -o -name "*.cpp" | xargs clang-format -i --style=file | |
| - name: Commit changes | |
| uses: stefanzweifel/git-auto-commit-action@v6 | |
| with: | |
| commit_message: "style: format code with clang-format" | |
| branch: ${{ github.head_ref }} | |
| # 确保获取最新状态 | |
| skip_fetch: false | |
| # 只格式化 src 目录的文件 | |
| file_pattern: "src/" |