diff --git a/.woodpecker.yml b/.woodpecker.yml index e13c99f..886bf49 100644 --- a/.woodpecker.yml +++ b/.woodpecker.yml @@ -59,42 +59,33 @@ steps: cache: false - name: update-gitops - image: alpine:latest - environment: - GITOPS_REPO_URL: - from_secret: GITOPS_REPO_URL - GITOPS_BRANCH: - from_secret: GITOPS_BRANCH - GITOPS_TOKEN: - from_secret: GITOPS_TOKEN + image: alpine/git:latest commands: - | set -e - apk add --no-cache git bash sed - SERVICE_IMAGE="registry.nxtgauge.com:5000/nxtgauge-rust-${SERVICE}:${CI_COMMIT_SHA}" - echo "Service: ${SERVICE}, Image: ${SERVICE_IMAGE}" + echo "Updating GitOps for ${SERVICE}" - # Clone gitops repo - GIT_REPO=$(echo "${GITOPS_REPO_URL}" | sed 's|https://||') - git clone "https://x-access-token:${GITOPS_TOKEN}@${GIT_REPO}" /tmp/gitops + # Clone gitops repo using cloned source from Woodpecker + git clone https://github.com/Traceworks2023/nxtgauge-gitops.git /tmp/gitops cd /tmp/gitops - git checkout ${GITOPS_BRANCH:-main} + git checkout main - # Find and update the image in backend overlay + # Update backend overlay BACKEND_OVERLAY="apps/nxtgauge-backend-rust/overlays/prod" if [ -f "${BACKEND_OVERLAY}/kustomization.yaml" ]; then - # Update to use SHA tag sed -i "s|image: registry.nxtgauge.com:5000/nxtgauge-rust-${SERVICE}:.*|image: registry.nxtgauge.com:5000/nxtgauge-rust-${SERVICE}:${CI_COMMIT_SHA}|" \ ${BACKEND_OVERLAY}/kustomization.yaml echo "Updated ${SERVICE} in ${BACKEND_OVERLAY}/kustomization.yaml" fi - # Commit if changed + # Commit and push if ! git diff --quiet; then + git config user.name "Woodpecker CI" + git config user.email "woodpecker@nxtgauge.com" git add -A git commit -m "ci: update ${SERVICE} to ${CI_COMMIT_SHA:0:8}" - git push origin ${GITOPS_BRANCH:-main} + git push origin main echo "Pushed GitOps update" else echo "No changes to push"