nxtgauge-ai-assistant/.forgejo/workflows/build.yaml
Ashwin Kumar Sivakumar 4becb73ab0
Some checks failed
build-and-release / build (push) Failing after 1m5s
fix(ci): push image to Forgejo registry and update GitOps repo over HTTPS
The GitOps step relied on GITEOPS_REPO/GITEOPS_SSH_KEY secrets that were
never configured, and the registry login used a REGISTRY_HOSTPORT secret
that doesn't match this repo's actual registry setup. Switch to the
Forgejo registry directly and push the GitOps update over HTTPS with a
token, matching how other services in this org already deploy.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-16 20:33:14 +05:30

82 lines
2.6 KiB
YAML

name: build-and-release
on:
push:
branches:
- main
- high-performance
concurrency:
group: ai-assistant-build-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
runs-on: docker-ready
env:
DOCKER_HOST: tcp://127.0.0.1:2375
DOCKER_BUILDKIT: "1"
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Docker Buildx
run: |
set -euo pipefail
for attempt in $(seq 1 30); do
if docker version >/dev/null 2>&1; then
break
fi
sleep 2
done
docker version
docker buildx create --use --name nxtgauge-builder || docker buildx use nxtgauge-builder
docker buildx inspect --bootstrap
- name: Login to Forgejo registry
env:
REGISTRY_HOST: ci.nxtgauge.com
REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }}
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
run: |
set -euo pipefail
printf '%s' "$REGISTRY_PASSWORD" | docker login "$REGISTRY_HOST" -u "$REGISTRY_USERNAME" --password-stdin
- name: Build and push image
env:
REGISTRY_HOST: ci.nxtgauge.com
SHA: ${{ github.sha }}
run: |
set -euo pipefail
image_ref="$REGISTRY_HOST/nxtgauge/nxtgauge-ai-assistant:$SHA"
docker buildx build --push \
-t "$image_ref" \
-t "$REGISTRY_HOST/nxtgauge/nxtgauge-ai-assistant:latest" \
-f Dockerfile \
.
- name: Update GitOps
env:
GITOPS_REPO: https://ci.nxtgauge.com/nxtgauge/nxtgauge-gitops.git
GITOPS_TOKEN: ${{ secrets.GITOPS_TOKEN }}
SHA: ${{ github.sha }}
run: |
set -euo pipefail
apk add --no-cache git
git config --global credential.helper '!f() { printf "%s\\n" "username=forgejo-actions"; printf "%s\\n" "password=$GITOPS_TOKEN"; }; f'
GITOPS_DIR=$(mktemp -d)
git clone "$GITOPS_REPO" "$GITOPS_DIR"
cd "$GITOPS_DIR"
# Update deployment image
sed -i "s|image: ci.nxtgauge.com/nxtgauge/nxtgauge-ai-assistant:.*|image: ci.nxtgauge.com/nxtgauge/nxtgauge-ai-assistant:$SHA|" apps/nxtgauge-ai-assistant/base/deployment.yaml
git config user.name "forgejo-actions[bot]"
git config user.email "forgejo-actions@ci.nxtgauge.com"
git add apps/nxtgauge-ai-assistant/base/deployment.yaml
git diff --quiet || (git commit -m "chore(gitops): deploy ai-assistant@${SHA}" && git push)