fix(woodpecker): handle shallow git clone for change detection
This commit is contained in:
parent
bce0f13f56
commit
08dde4f3e8
1 changed files with 12 additions and 4 deletions
|
|
@ -32,7 +32,18 @@ steps:
|
|||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
CHANGED_FILES=$(git diff --name-only HEAD~1 HEAD || echo "")
|
||||
# Fetch previous commit for comparison
|
||||
git fetch --depth=2 origin +refs/heads/${CI_COMMIT_BRANCH}:refs/remotes/origin/${CI_COMMIT_BRANCH} || true
|
||||
|
||||
# Get changed files (handle shallow clone)
|
||||
CHANGED_FILES=$(git diff --name-only HEAD~1 HEAD 2>/dev/null || git diff --name-only origin/${CI_COMMIT_BRANCH}~1 origin/${CI_COMMIT_BRANCH} 2>/dev/null || echo "ALL")
|
||||
|
||||
# If we can't detect changes, assume we should build
|
||||
if [ "$CHANGED_FILES" = "ALL" ] || [ -z "$CHANGED_FILES" ]; then
|
||||
echo "⚠️ Cannot detect changes for ${SERVICE}, assuming build needed"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
SERVICE_PATH=$(echo "${SERVICE}" | tr '_' '-')
|
||||
|
||||
SHARED_CHANGED=false
|
||||
|
|
@ -58,7 +69,6 @@ steps:
|
|||
- name: build-and-push
|
||||
image: woodpeckerci/plugin-docker-buildx:5.0.0
|
||||
settings:
|
||||
# Use internal registry
|
||||
registry: docker-registry.registry.svc.cluster.local:5000
|
||||
repo: docker-registry.registry.svc.cluster.local:5000/nxtgauge-rust-${SERVICE}
|
||||
dockerfile: Dockerfile.simple
|
||||
|
|
@ -68,7 +78,6 @@ steps:
|
|||
- ${CI_COMMIT_SHA}
|
||||
- latest
|
||||
- high-performance-latest
|
||||
# Use Docker Hub for base images
|
||||
logins:
|
||||
- registry: https://index.docker.io/v1/
|
||||
username:
|
||||
|
|
@ -76,6 +85,5 @@ steps:
|
|||
password:
|
||||
from_secret: DOCKERHUB_TOKEN
|
||||
platforms: linux/amd64
|
||||
# Enable caching from/to internal registry
|
||||
cache_from: docker-registry.registry.svc.cluster.local:5000/nxtgauge-rust-${SERVICE}:cache
|
||||
cache_to: docker-registry.registry.svc.cluster.local:5000/nxtgauge-rust-${SERVICE}:cache
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue