ci: simplify GitOps update to use Woodpecker's Git access
This commit is contained in:
parent
f67319c5f7
commit
c26f14f917
2 changed files with 9 additions and 23 deletions
|
|
@ -31,26 +31,16 @@ steps:
|
||||||
cache: false
|
cache: false
|
||||||
|
|
||||||
- name: update-gitops
|
- name: update-gitops
|
||||||
image: alpine:latest
|
image: alpine/git:latest
|
||||||
environment:
|
|
||||||
GITOPS_REPO_URL:
|
|
||||||
from_secret: GITOPS_REPO_URL
|
|
||||||
GITOPS_BRANCH:
|
|
||||||
from_secret: GITOPS_BRANCH
|
|
||||||
GITOPS_TOKEN:
|
|
||||||
from_secret: GITOPS_TOKEN
|
|
||||||
commands:
|
commands:
|
||||||
- |
|
- |
|
||||||
set -e
|
set -e
|
||||||
apk add --no-cache git bash sed
|
|
||||||
|
|
||||||
echo "Updating GitOps for nxtgauge-frontend-solid"
|
echo "Updating GitOps for nxtgauge-frontend-solid"
|
||||||
|
|
||||||
# Clone gitops repo
|
git clone https://github.com/Traceworks2023/nxtgauge-gitops.git /tmp/gitops
|
||||||
GIT_REPO=$(echo "${GITOPS_REPO_URL}" | sed 's|https://||')
|
|
||||||
git clone "https://x-access-token:${GITOPS_TOKEN}@${GIT_REPO}" /tmp/gitops
|
|
||||||
cd /tmp/gitops
|
cd /tmp/gitops
|
||||||
git checkout ${GITOPS_BRANCH:-main}
|
git checkout main
|
||||||
|
|
||||||
# Update frontend overlay
|
# Update frontend overlay
|
||||||
FRONTEND_OVERLAY="apps/nxtgauge-frontend-solid/overlays/prod"
|
FRONTEND_OVERLAY="apps/nxtgauge-frontend-solid/overlays/prod"
|
||||||
|
|
@ -60,19 +50,13 @@ steps:
|
||||||
echo "Updated frontend image to ${CI_COMMIT_SHA}"
|
echo "Updated frontend image to ${CI_COMMIT_SHA}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Also update base if needed
|
# Commit and push
|
||||||
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
|
if ! git diff --quiet; then
|
||||||
|
git config user.name "Woodpecker CI"
|
||||||
|
git config user.email "woodpecker@nxtgauge.com"
|
||||||
git add -A
|
git add -A
|
||||||
git commit -m "ci: update nxtgauge-frontend-solid to ${CI_COMMIT_SHA:0:8}"
|
git commit -m "ci: update nxtgauge-frontend-solid to ${CI_COMMIT_SHA:0:8}"
|
||||||
git push origin ${GITOPS_BRANCH:-main}
|
git push origin main
|
||||||
echo "Pushed GitOps update"
|
echo "Pushed GitOps update"
|
||||||
else
|
else
|
||||||
echo "No changes to push"
|
echo "No changes to push"
|
||||||
|
|
|
||||||
|
|
@ -130,3 +130,5 @@ vinxi starting dev server
|
||||||
2:18:48 PM [vite] (client) page reload .woodpecker.yml
|
2:18:48 PM [vite] (client) page reload .woodpecker.yml
|
||||||
2:26:51 PM [vite] (ssr) page reload .woodpecker.yml
|
2:26:51 PM [vite] (ssr) page reload .woodpecker.yml
|
||||||
2:26:51 PM [vite] (client) page reload .woodpecker.yml
|
2:26:51 PM [vite] (client) page reload .woodpecker.yml
|
||||||
|
2:28:11 PM [vite] (ssr) page reload .woodpecker.yml
|
||||||
|
2:28:11 PM [vite] (client) page reload .woodpecker.yml
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue