fix(woodpecker): use exit code 78 to skip builds instead of evaluate

This commit is contained in:
Ashwin Kumar 2026-04-10 05:27:39 +02:00
parent a3622de8e9
commit 2370f62eac

View file

@ -10,29 +10,26 @@ steps:
- |
#!/bin/bash
set -e
# Get changed files from last commit
CHANGED_FILES=$(git diff --name-only HEAD~1 HEAD || echo "")
# Check if relevant files changed (src, package.json, Dockerfile, etc.)
RELEVANT_CHANGED=false
if echo "$CHANGED_FILES" | grep -qE "^(src/|package\.json|package-lock\.json|Dockerfile|vite\.config|tsconfig|public/)"; then
RELEVANT_CHANGED=true
echo "✅ Admin panel code changed - will build"
fi
# Create marker file
# Exit with code 78 to skip subsequent steps if no changes
if [ "$RELEVANT_CHANGED" = "true" ]; then
echo "SHOULD_BUILD=true" > .build-marker
echo "🚀 Will build admin panel"
exit 0
else
echo "SHOULD_BUILD=false" > .build-marker
echo "⏭️ Skipping admin panel - no relevant changes"
exit 78
fi
# Export for other steps
cat .build-marker >> ${CI_ENV}
- name: build-and-push
image: woodpeckerci/plugin-docker-buildx:5.0.0
settings:
@ -48,8 +45,6 @@ steps:
password:
from_secret: GHCR_TOKEN
platforms: linux/amd64
when:
- evaluate: 'env.SHOULD_BUILD == "true"'
- name: deploy
image: bitnami/kubectl:latest
@ -60,49 +55,37 @@ steps:
- |
#!/bin/bash
set -e
# Check if we should deploy
if [ "${SHOULD_BUILD}" != "true" ]; then
echo "⏭️ Skipping deployment - no changes"
exit 0
fi
# Setup kubeconfig
mkdir -p ~/.kube
echo "$KUBE_CONFIG" | base64 -d > ~/.kube/config
chmod 600 ~/.kube/config
NAMESPACE="nxtgauge"
DEPLOYMENT_NAME="nxtgauge-admin-solid"
echo "🚀 Deploying admin panel..."
# Trigger rolling restart to pick up new image
kubectl rollout restart deployment/${DEPLOYMENT_NAME} -n ${NAMESPACE}
# Wait for rollout to complete
echo "⏳ Waiting for rollout to complete..."
kubectl rollout status deployment/${DEPLOYMENT_NAME} -n ${NAMESPACE} --timeout=300s
echo "✅ Admin panel deployed successfully!"
# Show deployment status
kubectl get deployment/${DEPLOYMENT_NAME} -n ${NAMESPACE}
when:
- evaluate: 'env.SHOULD_BUILD == "true"'
- name: notify
image: alpine:latest
commands:
- |
if [ "${SHOULD_BUILD}" = "true" ]; then
if [ "${CI_PIPELINE_STATUS}" = "success" ]; then
echo "✅ Admin panel pipeline completed successfully"
else
echo "❌ Admin panel pipeline failed"
fi
if [ "${CI_PIPELINE_STATUS}" = "success" ]; then
echo "✅ Admin panel pipeline completed successfully"
else
echo "⏭️ Admin panel was skipped (no changes)"
echo "❌ Admin panel pipeline failed"
fi
when:
- status: [success, failure]
status: [success, failure]