ci: simplify GitOps update to use Woodpecker's Git access
This commit is contained in:
parent
acfb25043b
commit
0886b88fe6
1 changed files with 7 additions and 23 deletions
|
|
@ -31,26 +31,16 @@ 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
|
||||
|
||||
echo "Updating GitOps for nxtgauge-admin-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
|
||||
git clone https://github.com/Traceworks2023/nxtgauge-gitops.git /tmp/gitops
|
||||
cd /tmp/gitops
|
||||
git checkout ${GITOPS_BRANCH:-main}
|
||||
git checkout main
|
||||
|
||||
# Update admin overlay
|
||||
ADMIN_OVERLAY="apps/nxtgauge-admin-solid/overlays/prod"
|
||||
|
|
@ -60,19 +50,13 @@ steps:
|
|||
echo "Updated admin image to ${CI_COMMIT_SHA}"
|
||||
fi
|
||||
|
||||
# Also update base if needed
|
||||
ADMIN_BASE="apps/nxtgauge-admin-solid/base"
|
||||
if [ -f "${ADMIN_BASE}/deployment.yaml" ]; then
|
||||
sed -i "s|image: registry.nxtgauge.com:5000/nxtgauge-admin-solid.*|image: registry.nxtgauge.com:5000/nxtgauge-admin-solid:${CI_COMMIT_SHA}|" \
|
||||
${ADMIN_BASE}/deployment.yaml
|
||||
echo "Updated admin base deployment"
|
||||
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 nxtgauge-admin-solid 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"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue