mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/4jcraft.git
synced 2026-09-23 10:12:26 +00:00
Co-Authored-By: MatthewBeshay <[email protected]> #163 got deleted.
69 lines
1.9 KiB
YAML
69 lines
1.9 KiB
YAML
name: Clang Format All
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
inputs:
|
|
commit_changes:
|
|
description: Commit formatted changes back to the selected branch
|
|
required: true
|
|
default: false
|
|
type: boolean
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
jobs:
|
|
clang-format-all:
|
|
runs-on: ubuntu-24.04
|
|
concurrency:
|
|
group: clang-format-all-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
ref: ${{ github.ref }}
|
|
|
|
- name: Install clang-format
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt-get install -y clang-format-19
|
|
|
|
- name: Format tracked C/C++ files
|
|
env:
|
|
CLANG_FORMAT_BIN: clang-format-19
|
|
run: |
|
|
bash ./.github/scripts/run-clang-format-all.sh apply
|
|
|
|
- name: Export patch
|
|
id: patch
|
|
run: |
|
|
if git diff --quiet; then
|
|
echo "changed=false" >> "$GITHUB_OUTPUT"
|
|
exit 0
|
|
fi
|
|
|
|
git diff --binary > clang-format-all.patch
|
|
echo "changed=true" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Upload patch artifact
|
|
if: steps.patch.outputs.changed == 'true'
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: clang-format-all-${{ github.sha }}
|
|
path: clang-format-all.patch
|
|
retention-days: 7
|
|
|
|
- name: Commit formatted changes
|
|
if: steps.patch.outputs.changed == 'true' && github.event.inputs.commit_changes == 'true'
|
|
run: |
|
|
git config user.name "github-actions[bot]"
|
|
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
|
git add -A
|
|
git commit -m "Run clang-format over tracked sources"
|
|
git push origin HEAD:${GITHUB_REF_NAME}
|
|
|
|
- name: Report no-op run
|
|
if: steps.patch.outputs.changed == 'false'
|
|
run: echo "clang-format produced no changes." |