Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
- Remove cache_from and cache_to that cause parsing errors - Keep pull: true for layer caching - Simpler configuration that works reliably - Docker will still use local cache automatically Error was: type required form> "ref=..." Cause: Woodpecker plugin doesn't support complex cache syntax
220 lines
6.4 KiB
YAML
220 lines
6.4 KiB
YAML
# Woodpecker CI/CD Pipeline - Peikarband Landing
|
|
# Application build pipeline with auto-build base image fallback
|
|
|
|
variables:
|
|
- &python_image 'python:3.11-slim'
|
|
- &helm_image 'alpine/helm:latest'
|
|
- &base_image 'hub.peikarband.ir/peikarband/base:latest'
|
|
|
|
when:
|
|
- event: [push, pull_request, tag, manual]
|
|
|
|
pipeline:
|
|
# ============================================
|
|
# Stage 1: Build Base Image (always - with cache)
|
|
# ============================================
|
|
|
|
build-base-image:
|
|
image: woodpeckerci/plugin-docker-buildx
|
|
settings:
|
|
registry: hub.peikarband.ir
|
|
repo: hub.peikarband.ir/peikarband/base
|
|
username:
|
|
from_secret: HARBOR_USERNAME
|
|
password:
|
|
from_secret: HARBOR_PASSWORD
|
|
|
|
dockerfile: docker/Dockerfile.base
|
|
context: .
|
|
platforms: linux/amd64
|
|
|
|
tags:
|
|
- latest
|
|
- python3.11-node20
|
|
|
|
build_args:
|
|
- PYTHON_VERSION=3.11
|
|
- NODE_VERSION=20
|
|
|
|
labels:
|
|
- org.opencontainers.image.created=${CI_PIPELINE_CREATED}
|
|
- org.opencontainers.image.source=${CI_REPO_LINK}
|
|
- org.opencontainers.image.title=Peikarband Base
|
|
|
|
pull: true
|
|
provenance: false
|
|
push: true
|
|
|
|
when:
|
|
event: [push, tag]
|
|
|
|
# ============================================
|
|
# Stage 2: Build Application Image
|
|
# ============================================
|
|
|
|
build-image:
|
|
image: woodpeckerci/plugin-docker-buildx
|
|
settings:
|
|
registry: hub.peikarband.ir
|
|
repo: hub.peikarband.ir/peikarband/landing
|
|
username:
|
|
from_secret: HARBOR_USERNAME
|
|
password:
|
|
from_secret: HARBOR_PASSWORD
|
|
|
|
dockerfile: docker/Dockerfile
|
|
context: .
|
|
platforms: linux/amd64
|
|
|
|
build_args:
|
|
- BASE_IMAGE=hub.peikarband.ir/peikarband/base:latest
|
|
- VERSION=${CI_COMMIT_SHA:0:8}
|
|
- BUILD_DATE=${CI_PIPELINE_CREATED}
|
|
|
|
tags:
|
|
- ${CI_COMMIT_SHA:0:8}
|
|
|
|
labels:
|
|
- org.opencontainers.image.created=${CI_PIPELINE_CREATED}
|
|
- org.opencontainers.image.source=${CI_REPO_LINK}
|
|
- org.opencontainers.image.url=${CI_REPO_LINK}
|
|
- org.opencontainers.image.revision=${CI_COMMIT_SHA}
|
|
- org.opencontainers.image.version=${CI_COMMIT_SHA:0:8}
|
|
- org.opencontainers.image.title=Peikarband Landing
|
|
- org.opencontainers.image.description=Peikarband hosting platform landing page
|
|
|
|
pull: true
|
|
provenance: false
|
|
push: false
|
|
|
|
when:
|
|
event: [push, tag]
|
|
branch: [main, develop, feature/restructure-project]
|
|
|
|
# ============================================
|
|
# Stage 3: Push Application Image
|
|
# ============================================
|
|
|
|
push-image:
|
|
image: woodpeckerci/plugin-docker-buildx
|
|
settings:
|
|
registry: hub.peikarband.ir
|
|
repo: hub.peikarband.ir/peikarband/landing
|
|
username:
|
|
from_secret: HARBOR_USERNAME
|
|
password:
|
|
from_secret: HARBOR_PASSWORD
|
|
|
|
dockerfile: docker/Dockerfile
|
|
context: .
|
|
platforms: linux/amd64
|
|
|
|
build_args:
|
|
- BASE_IMAGE=hub.peikarband.ir/peikarband/base:latest
|
|
- VERSION=${CI_COMMIT_SHA:0:8}
|
|
- BUILD_DATE=${CI_PIPELINE_CREATED}
|
|
|
|
tags:
|
|
- latest
|
|
- ${CI_COMMIT_SHA:0:8}
|
|
- ${CI_COMMIT_BRANCH}
|
|
|
|
labels:
|
|
- org.opencontainers.image.created=${CI_PIPELINE_CREATED}
|
|
- org.opencontainers.image.source=${CI_REPO_LINK}
|
|
- org.opencontainers.image.url=${CI_REPO_LINK}
|
|
- org.opencontainers.image.revision=${CI_COMMIT_SHA}
|
|
- org.opencontainers.image.version=${CI_COMMIT_SHA:0:8}
|
|
- org.opencontainers.image.title=Peikarband Landing
|
|
- org.opencontainers.image.description=Peikarband hosting platform landing page
|
|
|
|
pull: true
|
|
provenance: false
|
|
push: true
|
|
|
|
when:
|
|
event: [push, tag]
|
|
branch: [main, develop, feature/restructure-project]
|
|
|
|
# ============================================
|
|
# Stage 4: Verify Push
|
|
# ============================================
|
|
|
|
verify-push:
|
|
image: alpine:latest
|
|
commands:
|
|
- apk add --no-cache curl
|
|
- |
|
|
echo "Verifying image was pushed successfully..."
|
|
sleep 3
|
|
|
|
REGISTRY="hub.peikarband.ir"
|
|
REPO="peikarband/landing"
|
|
TAG="${CI_COMMIT_SHA:0:8}"
|
|
|
|
if curl -f -u "$HARBOR_USERNAME:$HARBOR_PASSWORD" \
|
|
"https://$REGISTRY/v2/$REPO/manifests/$TAG" > /dev/null 2>&1; then
|
|
echo "✓ Image verified: $REGISTRY/$REPO:$TAG"
|
|
else
|
|
echo "❌ Failed to verify image push"
|
|
exit 1
|
|
fi
|
|
secrets: [HARBOR_USERNAME, HARBOR_PASSWORD]
|
|
when:
|
|
event: [push, tag]
|
|
branch: [main, develop, feature/restructure-project]
|
|
|
|
# ============================================
|
|
# Notifications
|
|
# ============================================
|
|
|
|
notify-success:
|
|
image: alpine:latest
|
|
commands:
|
|
- echo "🎉 Pipeline completed successfully!"
|
|
- echo "Branch:" "${CI_COMMIT_BRANCH}"
|
|
- echo "Commit:" "${CI_COMMIT_SHA:0:8}"
|
|
- echo "Image:" "hub.peikarband.ir/peikarband/landing:${CI_COMMIT_SHA:0:8}"
|
|
when:
|
|
event: [push, tag]
|
|
status: success
|
|
|
|
notify-failure:
|
|
image: alpine:latest
|
|
commands:
|
|
- echo "❌ Pipeline failed!"
|
|
- echo "Branch:" "${CI_COMMIT_BRANCH}"
|
|
- echo "Commit:" "${CI_COMMIT_SHA:0:8}"
|
|
- echo "Please check the logs above"
|
|
when:
|
|
event: [push, tag]
|
|
status: failure
|
|
|
|
# ============================================
|
|
# Commented stages (enable when needed)
|
|
# ============================================
|
|
|
|
# helm-lint:
|
|
# image: *helm_image
|
|
# commands:
|
|
# - helm lint helm/peikarband
|
|
# when:
|
|
# event: [push, pull_request, tag]
|
|
|
|
# deploy-staging:
|
|
# image: *helm_image
|
|
# commands:
|
|
# - apk add --no-cache kubectl
|
|
# - echo "$KUBECONFIG_STAGING" | base64 -d > /tmp/kubeconfig
|
|
# - export KUBECONFIG=/tmp/kubeconfig
|
|
# - helm upgrade --install peikarband-staging helm/peikarband \
|
|
# --namespace staging \
|
|
# --create-namespace \
|
|
# --set image.repository=hub.peikarband.ir/peikarband/landing \
|
|
# --set image.tag=${CI_COMMIT_SHA:0:8} \
|
|
# --wait --timeout 5m
|
|
# secrets: [KUBECONFIG_STAGING]
|
|
# when:
|
|
# event: push
|
|
# branch: [main, develop]
|