From c328384735b419e8dde12d1dd02f3bd899a06ee4 Mon Sep 17 00:00:00 2001 From: oduortoni Date: Fri, 13 Feb 2026 11:41:52 +0300 Subject: [PATCH] fix(cicd): skip auto commit if no changes --- .github/workflows/build-and-test.yml | 36 +++++++++++++++++----------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 44e34ea..f0686e3 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -4,21 +4,17 @@ on: push: branches: - main - env: BUILD_TYPE: debug CC: gcc-14 - jobs: build-and-test: runs-on: ubuntu-latest permissions: contents: write pull-requests: write - container: image: koutoftimer/oduortoni-c-http-server-actions:latest - steps: - name: Checkout repository uses: actions/checkout@v4 @@ -29,25 +25,37 @@ jobs: - name: Auto-format code run: | + set -x # Enable debug output + git config --global --add safe.directory $PWD git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" - # Set up authentication - git remote set-url origin https://x-access-token:${{ secrets.PAT_TOKEN }}@github.com/${{ github.repository }}.git - # Run formatting pre-commit run --all-files || true - # Only push if there are actual changes - if ! git diff --quiet; then - git add -A - git commit -m "style: auto-format code with clang-format [skip ci]" - git push - echo "✓ Code formatted and pushed" - else + # Debug: show git status + echo "=== Git Status ===" + git status + echo "=== Git Diff ===" + git diff + echo "=== Porcelain ===" + git status --porcelain + + # Exit early if no changes + if [ -z "$(git status --porcelain)" ]; then echo "✓ No formatting changes needed" + exit 0 fi + + # Only set up git remote if we actually need to push + echo "Changes detected, setting up authentication..." + git remote set-url origin https://x-access-token:${{ secrets.PAT_TOKEN }}@github.com/${{ github.repository }}.git + + git add -A + git commit -m "style: auto-format code with clang-format [skip ci]" + git push + echo "✓ Code formatted and pushed" - name: Build C code run: |