From 24489430abee3d603022822d3e70b158233a3d0a Mon Sep 17 00:00:00 2001 From: Tamas Vami Date: Tue, 17 Sep 2024 12:30:29 -0700 Subject: [PATCH] Auto-commit clang format --- .github/workflows/format-check.yml | 32 ++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/.github/workflows/format-check.yml b/.github/workflows/format-check.yml index c5e91db3f..5b64b5be6 100644 --- a/.github/workflows/format-check.yml +++ b/.github/workflows/format-check.yml @@ -1,4 +1,4 @@ -name: Check Format +name: Check/apply clang-format on: push: branches: @@ -9,9 +9,29 @@ jobs: clang-format: runs-on: ubuntu-latest steps: - - uses: extractions/setup-just@v2 - with: + - name: Install just + uses: extractions/setup-just@v2 + with: just-version: 1.26.0 - - uses: actions/checkout@v4 - - name: run format check on the C++ - run: just install-denv init format-cpp --verbose -Werror --dry-run + + - uses: actions/checkout@v4 + + - name: Pull latest changes + run: | + git fetch origin ${GITHUB_HEAD_REF} + git checkout ${GITHUB_HEAD_REF} + git pull origin ${GITHUB_HEAD_REF} + + - name: Run format check on the C++ + run: just install-denv init format-cpp + + - name: Set up git user as the bot + run: | + git config user.name 'github-actions[bot]' + git config user.email 'github-actions[bot]@users.noreply.github.com' + + - name: Auto-commit the changes + run: | + git add . + git commit -m "Apply clang-format" || echo "No changes to commit" + git push origin HEAD:${GITHUB_HEAD_REF}