diff --git a/Dockerfile b/Dockerfile index f4c481b..6d3cdf6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,15 @@ -FROM woodpeckerci/plugin-kaniko:latest +FROM alpine:3.19 -USER root - -# מתקין את הכלים שאתה צריך לפעולת העדכון (למשל yq, git) +# התקנת כלים שאתה צריך RUN apk add --no-cache bash git yq curl +# הורדת Kaniko +RUN mkdir -p /kaniko && \ + curl -sSL -o /kaniko/executor https://github.com/GoogleContainerTools/kaniko/releases/download/v1.21.0/executor && \ + chmod +x /kaniko/executor + +ENV PATH="/kaniko:$PATH" + COPY entrypoint.sh /entrypoint.sh RUN chmod +x /entrypoint.sh diff --git a/entrypoint.sh b/entrypoint.sh index 638b4c3..871601c 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash set -e echo "🚀 Starting wp-kaniko-sync" @@ -6,7 +6,6 @@ echo "🚀 Starting wp-kaniko-sync" TAG="${CI_COMMIT_BRANCH}-${CI_COMMIT_SHA:0:7}" echo "🧩 Using tag: $TAG" -echo "🔨 Building Docker image for ${PLUGIN_CONTEXT}" /kaniko/executor \ --dockerfile="${PLUGIN_DOCKERFILE}" \ --context="${PLUGIN_CONTEXT}" \ @@ -17,3 +16,16 @@ echo "🔨 Building Docker image for ${PLUGIN_CONTEXT}" --cleanup echo "✅ Image pushed successfully" + +if [[ -n "$PLUGIN_GIT_REPO" ]]; then + git config --global user.name "woodpecker-bot" + git config --global user.email "ci@dvirlabs.com" + git clone "https://${PLUGIN_GIT_USERNAME}:${PLUGIN_GIT_TOKEN}@${PLUGIN_GIT_REPO}" + cd $(basename "$PLUGIN_GIT_REPO" .git) + + yq -i ".$PLUGIN_VALUES_PATH = \"$TAG\"" "$PLUGIN_VALUES_FILE" + + git add "$PLUGIN_VALUES_FILE" + git commit -m "${PLUGIN_NAME}: update tag to $TAG" || echo "⚠️ No changes" + git push origin HEAD +fi