Skip to content

Committing clang-format changes d25cdf9 #39

Committing clang-format changes d25cdf9

Committing clang-format changes d25cdf9 #39

Workflow file for this run

name: clang-format
on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
workflow_dispatch:
inputs:
lint_mode:
description: 'Select lint mode: check_only, auto_commit, or create_pr'
required: true
default: 'check_only'
type: choice
options:
- check_only
- create_pr
- auto_commit
env:
lint_mode: "${{ inputs.lint_mode || 'check_only' }}"
jobs:
clang-format-lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Set LAST_COMMIT_HASH (short)
run: echo "LAST_COMMIT_HASH=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
- name: Run clang-format lint
uses: DoozyX/clang-format-lint-action@v0.20
with:
source: './axmol ./extensions ./tests ./templates'
exclude: './3rdparty ./extensions/ImGui/**/im* ./extensions/fairygui ./extensions/Live2D ./extensions/Effekseer ./extensions/scripting/lua-bindings/auto ./extensions/spine ./tests/fairygui-tests ./extensions/**/*_generated.h'
extensions: 'h,cpp,c,mm'
clangFormatVersion: 20
inplace: True
- name: Check for uncommitted changes
if: ${{ env.lint_mode == 'check_only' }}
shell: pwsh
run: |
git diff --quiet
if ($LASTEXITCODE -ne 0) {
Write-Host "❌ clang-format check failed: Uncommitted formatting changes detected."
Write-Host "=== The following differences require formatting ==="
git --no-pager diff
Write-Host "===================================================="
exit 1
}
else {
Write-Host "✅ clang-format check passed: No formatting changes needed."
}
- name: Create pull request
if: ${{ env.lint_mode == 'create_pr' }}
id: cpr
uses: peter-evans/create-pull-request@v7
with:
token: ${{ secrets.AX_BOT_TOKEN }}
push-to-fork: axmol-bot/axmol
commit-message: Committing clang-format changes
signoff: false
branch: clang_format_for_${{ env.LAST_COMMIT_HASH }}
delete-branch: true
title: 'Committing clang-format changes ${{ env.LAST_COMMIT_HASH }}'
body: |
RT
- Auto-generated by [create-pull-request][1]
[1]: https://github.com/peter-evans/create-pull-request
labels: |
lua-bindings
automated pr
pinned
assignees: axmol-bot
reviewers: halx99
draft: false
- name: Check pull request outputs
if: ${{ env.lint_mode == 'create_pr' && steps.cpr.outputs.pull-request-number }}
run: |
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}"
- name: Commit clang-format changes to PR source branch
if: ${{ env.lint_mode == 'auto_commit' && github.head_ref }}
uses: EndBug/add-and-commit@v9
with:
author_name: axmol-bot
author_email: 116471739+axmol-bot@users.noreply.github.com
committer_name: GitHub Actions
committer_email: 41898282+github-actions[bot]@users.noreply.github.com
message: 'Committing clang-format changes'
new_branch: ${{ github.head_ref || github.ref_name }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}