From 92efae1df947bb0de38e6c578cf311b587dae856 Mon Sep 17 00:00:00 2001 From: John Ogle Date: Mon, 11 May 2026 21:45:47 -0700 Subject: [PATCH] ci(openclaw): skip image build when no openclaw-related files changed Add openclaw-changes gate job that uses git diff to detect changes in openclaw-relevant paths (packages/openclaw-image/, packages/default.nix, flake.nix, flake.lock, ci.yml). The build-and-push-openclaw job now only runs when the gate reports changed=true, avoiding unnecessary Docker image builds on unrelated pushes to main. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus --- .gitea/workflows/ci.yml | 52 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 50 insertions(+), 2 deletions(-) diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index e9b865a..6cd3aa6 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -108,11 +108,59 @@ jobs: env: NIX_CONFIG: "access-tokens = git.johnogle.info=${{ secrets.GITEA_ACCESS_TOKEN }}" - build-and-push-openclaw: - name: Build & Push OpenClaw Image + openclaw-changes: + name: Check OpenClaw Changes runs-on: ubuntu-latest needs: check if: github.event_name == 'push' && github.ref == 'refs/heads/main' + outputs: + changed: ${{ steps.filter.outputs.changed }} + steps: + - uses: actions/checkout@v6 + with: + fetch-depth: 0 + + - name: Check for OpenClaw-related changes + id: filter + run: | + # Files/directories that affect the openclaw image build + OPENCLAW_PATHS=( + 'packages/openclaw-image/' + 'packages/default.nix' + 'flake.nix' + 'flake.lock' + '.gitea/workflows/ci.yml' + ) + + PREV_SHA="${{ github.event.before }}" + # If before sha is all zeros (new branch), compare against initial commit + if [ "$PREV_SHA" = "0000000000000000000000000000000000000000" ]; then + PREV_SHA=$(git rev-list --max-parents=0 HEAD) + fi + + # If the before SHA doesn't exist in the repo (e.g. force push), + # fall back to comparing against the previous commit on the branch + if ! git rev-parse "$PREV_SHA" >/dev/null 2>&1; then + echo "Warning: before SHA $PREV_SHA not found, falling back to HEAD^" + PREV_SHA="HEAD^" + fi + + CHANGED=false + for path in "${OPENCLAW_PATHS[@]}"; do + if git diff --name-only "$PREV_SHA" "${{ github.sha }}" -- "$path" | grep -q .; then + echo "Change detected in: $path" + CHANGED=true + break + fi + done + + echo "changed=$CHANGED" >> $GITHUB_OUTPUT + + build-and-push-openclaw: + name: Build & Push OpenClaw Image + runs-on: ubuntu-latest + needs: openclaw-changes + if: needs.openclaw-changes.outputs.changed == 'true' outputs: image_tag: ${{ steps.meta.outputs.tag }} steps: