ci: add GitOps update step to Woodpecker pipeline
- After building, update nxtgauge-gitops with new SHA tag - Requires secrets: GITOPS_REPO_URL, GITOPS_BRANCH, GITOPS_TOKEN
This commit is contained in:
parent
7c99698d14
commit
b4cdfec3b5
1 changed files with 56 additions and 0 deletions
|
|
@ -1,3 +1,9 @@
|
||||||
|
# Woodpecker CI - Frontend build + GitOps update
|
||||||
|
#
|
||||||
|
# Secrets required:
|
||||||
|
# - REGISTRY_HOSTPORT, REGISTRY_USERNAME, REGISTRY_PASSWORD (existing)
|
||||||
|
# - GITOPS_REPO_URL, GITOPS_BRANCH, GITOPS_TOKEN, GITOPS_USERNAME, GITOPS_EMAIL
|
||||||
|
|
||||||
when:
|
when:
|
||||||
branch: [main, high-performance]
|
branch: [main, high-performance]
|
||||||
event: push
|
event: push
|
||||||
|
|
@ -23,3 +29,53 @@ steps:
|
||||||
skip_tls_verify: true
|
skip_tls_verify: true
|
||||||
platforms: linux/amd64
|
platforms: linux/amd64
|
||||||
cache: false
|
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
|
||||||
|
commands:
|
||||||
|
- |
|
||||||
|
set -e
|
||||||
|
apk add --no-cache git bash sed
|
||||||
|
|
||||||
|
echo "Updating GitOps for nxtgauge-frontend-solid"
|
||||||
|
|
||||||
|
# Clone gitops repo
|
||||||
|
GIT_REPO=$(echo "${GITOPS_REPO_URL}" | sed 's|https://||')
|
||||||
|
git clone "https://x-access-token:${GITOPS_TOKEN}@${GIT_REPO}" /tmp/gitops
|
||||||
|
cd /tmp/gitops
|
||||||
|
git checkout ${GITOPS_BRANCH:-main}
|
||||||
|
|
||||||
|
# Update frontend overlay
|
||||||
|
FRONTEND_OVERLAY="apps/nxtgauge-frontend-solid/overlays/prod"
|
||||||
|
if [ -f "${FRONTEND_OVERLAY}/kustomization.yaml" ]; then
|
||||||
|
sed -i "s|image: registry.nxtgauge.com:5000/nxtgauge-frontend-solid:.*|image: registry.nxtgauge.com:5000/nxtgauge-frontend-solid:${CI_COMMIT_SHA}|" \
|
||||||
|
${FRONTEND_OVERLAY}/kustomization.yaml
|
||||||
|
echo "Updated frontend image to ${CI_COMMIT_SHA}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Also update base if needed
|
||||||
|
FRONTEND_BASE="apps/nxtgauge-frontend-solid/base"
|
||||||
|
if [ -f "${FRONTEND_BASE}/deployment.yaml" ]; then
|
||||||
|
sed -i "s|image: registry.nxtgauge.com:5000/nxtgauge-frontend-solid.*|image: registry.nxtgauge.com:5000/nxtgauge-frontend-solid:${CI_COMMIT_SHA}|" \
|
||||||
|
${FRONTEND_BASE}/deployment.yaml
|
||||||
|
echo "Updated frontend base deployment"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Commit if changed
|
||||||
|
if ! git diff --quiet; then
|
||||||
|
git add -A
|
||||||
|
git commit -m "ci: update nxtgauge-frontend-solid to ${CI_COMMIT_SHA:0:8}"
|
||||||
|
git push origin ${GITOPS_BRANCH:-main}
|
||||||
|
echo "Pushed GitOps update"
|
||||||
|
else
|
||||||
|
echo "No changes to push"
|
||||||
|
fi
|
||||||
|
when:
|
||||||
|
status: success
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue