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 <clio-agent@sisyphuslabs.ai>
This commit is contained in:
+50
-2
@@ -108,11 +108,59 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
NIX_CONFIG: "access-tokens = git.johnogle.info=${{ secrets.GITEA_ACCESS_TOKEN }}"
|
NIX_CONFIG: "access-tokens = git.johnogle.info=${{ secrets.GITEA_ACCESS_TOKEN }}"
|
||||||
|
|
||||||
build-and-push-openclaw:
|
openclaw-changes:
|
||||||
name: Build & Push OpenClaw Image
|
name: Check OpenClaw Changes
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: check
|
needs: check
|
||||||
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
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:
|
outputs:
|
||||||
image_tag: ${{ steps.meta.outputs.tag }}
|
image_tag: ${{ steps.meta.outputs.tag }}
|
||||||
steps:
|
steps:
|
||||||
|
|||||||
Reference in New Issue
Block a user