nxtgauge-ai-assistant/.forgejo/workflows/build.yaml
Ashwin Kumar Sivakumar 1a73e6ac04
Some checks failed
build-and-release / build (push) Failing after 18s
fix(ci): push to the ashwin/ registry namespace, not the nonexistent nxtgauge org
Second failure: pushing to ci.nxtgauge.com/nxtgauge/nxtgauge-ai-assistant
404'd because no "nxtgauge" org exists on this Forgejo instance. The image
this app actually runs (verified against the live k8s deployment) lives
under ci.nxtgauge.com/ashwin/nxtgauge-ai-assistant, and the real GitOps
target is apps/nxtgauge-ai-assistant/overlays/prod/release-patch.yaml in
ashwin/nxtgauge-gitops (which Flux's image-automation-controller also
tracks via its $imagepolicy marker), not base/deployment.yaml.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-16 23:47:59 +05:30

97 lines
3.5 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_BUILDKIT: "1"
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Point DOCKER_HOST at this container's own gateway
run: |
set -euo pipefail
# 127.0.0.1 doesn't work: the job container is nested one level
# inside the runner pod's dind sidecar, so its own loopback isn't
# the sidecar's. Read the container's actual default-route gateway
# from /proc/net/route instead (the dind engine that spawned it).
GATEWAY="$(awk '$2 == "00000000" {print $3}' /proc/net/route | head -1 | \
sed -E 's/(..)(..)(..)(..)/0x\4 0x\3 0x\2 0x\1/' | \
{ read -r a b c d; printf '%d.%d.%d.%d' "$a" "$b" "$c" "$d"; })"
echo "Detected docker host gateway: $GATEWAY"
echo "DOCKER_HOST=tcp://$GATEWAY:2375" >> "$GITHUB_ENV"
- 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/ashwin/nxtgauge-ai-assistant:$SHA"
docker buildx build --push \
-t "$image_ref" \
-t "$REGISTRY_HOST/ashwin/nxtgauge-ai-assistant:latest" \
-f Dockerfile \
.
- name: Update GitOps
env:
GITOPS_REPO: https://ci.nxtgauge.com/ashwin/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"
# release-patch.yaml carries a Flux $imagepolicy marker comment on
# this line - Flux's own image-automation-controller would
# eventually rewrite it too, but committing here makes the new
# tag live immediately instead of waiting on Flux's poll interval.
sed -i -E "s|(image: ci\.nxtgauge\.com/ashwin/nxtgauge-ai-assistant:)[a-f0-9]+|\1$SHA|" apps/nxtgauge-ai-assistant/overlays/prod/release-patch.yaml
git config user.name "forgejo-actions[bot]"
git config user.email "forgejo-actions@ci.nxtgauge.com"
git add apps/nxtgauge-ai-assistant/overlays/prod/release-patch.yaml
git diff --quiet || (git commit -m "chore(gitops): deploy ai-assistant@${SHA}" && git push)