fix(ci): use GITOPS_PAT over HTTPS for gitops push, not never-configured GITEOPS_REPO/SSH secrets
Some checks failed
build-and-release / build (push) Failing after 1m4s

This commit is contained in:
ci-fix 2026-07-07 22:41:03 +00:00
parent 86ad5bc751
commit af87783d57

View file

@ -82,33 +82,47 @@ jobs:
- name: Update GitOps release - name: Update GitOps release
env: env:
GITEOPS_REPO: ${{ secrets.GITEOPS_REPO }} GITOPS_SERVER: ${{ secrets.GITOPS_SERVER || 'ci.nxtgauge.com' }}
GITEOPS_SSH_KEY: ${{ secrets.GITEOPS_SSH_KEY }} GITOPS_OWNER: ${{ secrets.GITOPS_OWNER || 'ashwin' }}
GITOPS_REPO: ${{ secrets.GITOPS_REPO || 'nxtgauge-gitops' }}
GITOPS_BRANCH: ${{ secrets.GITOPS_BRANCH || 'main' }}
# The gitops repo lives on Forgejo (ci.nxtgauge.com), not GitHub.
# GITEOPS_REPO/GITEOPS_SSH_KEY were never configured as repo
# secrets; use GITOPS_PAT instead, matching backend-rust.
GITOPS_PAT: ${{ secrets.GITOPS_PAT }}
SHA: ${{ github.sha }} SHA: ${{ github.sha }}
run: | run: |
set -euo pipefail set -euo pipefail
test -n "$GITEOPS_REPO" test -n "${GITOPS_PAT:-}" || { echo "GITOPS_PAT is empty"; exit 1; }
test -n "$GITEOPS_SSH_KEY"
mkdir -p ~/.ssh
printf '%s\n' "$GITEOPS_SSH_KEY" > ~/.ssh/id_ed25519
chmod 600 ~/.ssh/id_ed25519
ssh-keyscan github.com >> ~/.ssh/known_hosts 2>/dev/null
GITEOPS_DIR=$(mktemp -d) GITEOPS_DIR=$(mktemp -d)
git clone "$GITEOPS_REPO" "$GITEOPS_DIR" git clone "https://forgejo-actions:${GITOPS_PAT}@${GITOPS_SERVER}/${GITOPS_OWNER}/${GITOPS_REPO}.git" "$GITEOPS_DIR"
cd "$GITEOPS_DIR" cd "$GITEOPS_DIR"
image_ref="$(cat /tmp/ai-assistant-image-ref.txt)" image_ref="$(cat /tmp/ai-assistant-image-ref.txt)"
./scripts/set-app-release.sh ai-assistant "$image_ref"
if git diff --quiet; then for attempt in 1 2 3 4 5; do
echo "GitOps repo already up to date." git checkout "$GITOPS_BRANCH"
exit 0 ./scripts/set-app-release.sh ai-assistant "$image_ref"
fi
git config user.name "forgejo-actions[bot]" if git diff --quiet; then
git config user.email "forgejo-actions@ci.nxtgauge.com" echo "GitOps repo already up to date."
git add apps scripts/set-app-release.sh exit 0
git commit -m "chore(gitops): deploy ai-assistant@${SHA}" fi
git push
git config user.name "forgejo-actions[bot]"
git config user.email "forgejo-actions@ci.nxtgauge.com"
git add apps scripts/set-app-release.sh
git commit -m "chore(gitops): deploy ai-assistant@${SHA}"
if git push origin "HEAD:$GITOPS_BRANCH"; then
exit 0
fi
echo "Push rejected (attempt $attempt), pulling latest and retrying..."
git fetch origin "$GITOPS_BRANCH"
git reset --hard "origin/$GITOPS_BRANCH"
done
echo "Failed to push GitOps update after retries" >&2
exit 1