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: