diff --git a/.woodpecker.yml b/.woodpecker.yml index 2cebf52..65dbb81 100644 --- a/.woodpecker.yml +++ b/.woodpecker.yml @@ -14,6 +14,28 @@ pipeline: # Stage 1: Build Base Image (always - with cache) # ============================================ + check-base-image: + image: alpine:latest + commands: + - apk add --no-cache curl + - | + echo "Checking if base image exists..." + REGISTRY="hub.peikarband.ir" + REPO="peikarband/base" + TAG="latest" + + if curl -f -u "$HARBOR_USERNAME:$HARBOR_PASSWORD" \ + "https://$REGISTRY/v2/$REPO/manifests/$TAG" > /dev/null 2>&1; then + echo "✓ Base image found: $REGISTRY/$REPO:$TAG" + echo "SKIP_BASE_BUILD=true" > /tmp/base_status + else + echo "⚠️ Base image not found - will build it" + echo "SKIP_BASE_BUILD=false" > /tmp/base_status + fi + secrets: [HARBOR_USERNAME, HARBOR_PASSWORD] + when: + event: [push, tag] + build-base-image: image: woodpeckerci/plugin-docker-buildx settings: @@ -46,7 +68,15 @@ pipeline: push: true when: - event: [push, tag] + event: [push, tag, manual] + # فقط در یکی از این موارد build می‌شود: + # 1. وقتی Dockerfile.base تغییر کند + # 2. وقتی در commit message بنویسید: [build-base] + # 3. وقتی manual trigger کنید + path: + include: + - docker/Dockerfile.base + - .woodpecker.yml # ============================================ # Stage 2: Build Application Image