fix(woodpecker): handle shallow git clone for change detection
This commit is contained in:
parent
a6c88666ec
commit
a9227252e8
1 changed files with 11 additions and 4 deletions
|
|
@ -11,7 +11,17 @@ steps:
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e
|
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, assuming build needed"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
# Skip if only docs changed
|
# Skip if only docs changed
|
||||||
if echo "$CHANGED_FILES" | grep -qE "^\.github/|^\.woodpecker|\.md$"; then
|
if echo "$CHANGED_FILES" | grep -qE "^\.github/|^\.woodpecker|\.md$"; then
|
||||||
|
|
@ -38,7 +48,6 @@ steps:
|
||||||
- name: build-and-push
|
- name: build-and-push
|
||||||
image: woodpeckerci/plugin-docker-buildx:5.0.0
|
image: woodpeckerci/plugin-docker-buildx:5.0.0
|
||||||
settings:
|
settings:
|
||||||
# Use internal registry
|
|
||||||
registry: docker-registry.registry.svc.cluster.local:5000
|
registry: docker-registry.registry.svc.cluster.local:5000
|
||||||
repo: docker-registry.registry.svc.cluster.local:5000/nxtgauge-admin-solid
|
repo: docker-registry.registry.svc.cluster.local:5000/nxtgauge-admin-solid
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
|
|
@ -46,7 +55,6 @@ steps:
|
||||||
- ${CI_COMMIT_SHA}
|
- ${CI_COMMIT_SHA}
|
||||||
- latest
|
- latest
|
||||||
- high-performance-latest
|
- high-performance-latest
|
||||||
# Use Docker Hub for base images
|
|
||||||
logins:
|
logins:
|
||||||
- registry: https://index.docker.io/v1/
|
- registry: https://index.docker.io/v1/
|
||||||
username:
|
username:
|
||||||
|
|
@ -54,6 +62,5 @@ steps:
|
||||||
password:
|
password:
|
||||||
from_secret: DOCKERHUB_TOKEN
|
from_secret: DOCKERHUB_TOKEN
|
||||||
platforms: linux/amd64
|
platforms: linux/amd64
|
||||||
# Enable caching from/to internal registry
|
|
||||||
cache_from: docker-registry.registry.svc.cluster.local:5000/nxtgauge-admin-solid:cache
|
cache_from: docker-registry.registry.svc.cluster.local:5000/nxtgauge-admin-solid:cache
|
||||||
cache_to: docker-registry.registry.svc.cluster.local:5000/nxtgauge-admin-solid:cache
|
cache_to: docker-registry.registry.svc.cluster.local:5000/nxtgauge-admin-solid:cache
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue