Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 22 additions & 14 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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: |
Expand Down
Loading