From 768a3f6f82db3f3cfb7723754377cdead60f8626 Mon Sep 17 00:00:00 2001 From: "Rodrigo Rodriguez (Pragmatismo)" Date: Fri, 10 Apr 2026 08:36:05 -0300 Subject: [PATCH] ci: fix change detection - compare commits not diff --- .forgejo/workflows/botserver.yaml | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/.forgejo/workflows/botserver.yaml b/.forgejo/workflows/botserver.yaml index 500d0f78..e02107aa 100644 --- a/.forgejo/workflows/botserver.yaml +++ b/.forgejo/workflows/botserver.yaml @@ -121,28 +121,24 @@ jobs: # Check if there are changes to rebuild (check botserver submodule) cd /opt/gbo/data/botserver/botserver git fetch origin main - # Compare against origin/main - show what would be deployed - CHANGES=$(git diff HEAD origin/main --name-only 2>/dev/null | head -20 || echo "") - echo "=== Changes detected in botserver ===" - echo "$CHANGES" - echo "=======================================" - if [ -z "$CHANGES" ]; then - echo "No changes detected in botserver submodule" - else - echo "Changes detected in botserver, will rebuild" - fi + # Get current commit and origin/main commit + CURRENT_COMMIT=$(git rev-parse HEAD 2>/dev/null || echo "") + ORIGIN_COMMIT=$(git rev-parse origin/main 2>/dev/null || echo "") + echo "Current commit: $CURRENT_COMMIT" + echo "Origin commit: $ORIGIN_COMMIT" - cd /opt/gbo/data/botserver - - # Build only if there are changes OR binary doesn't exist - if [ -z "$CHANGES" ] && [ -f /opt/gbo/data/botserver/target/debug/botserver ]; then - echo "Binary already exists and no changes, skipping build" + # Compare commits - if different, there are changes to deploy + if [ "$CURRENT_COMMIT" = "$ORIGIN_COMMIT" ] && [ -f /opt/gbo/data/botserver/target/debug/botserver ]; then + echo "No changes - already at origin/main and binary exists, skipping build" echo "=== sccache stats ===" sccache --show-stats || true exit 0 fi + echo "Changes detected or no binary - will build" + + cd /opt/gbo/data/botserver echo "=== Starting build in background ===" cargo build -p botserver -j 8 > /tmp/build.log 2>&1 & BUILD_PID=$!