Compare commits
No commits in common. "high-performance" and "main" have entirely different histories.
high-perfo
...
main
7 changed files with 120 additions and 193 deletions
|
|
@ -1,96 +0,0 @@
|
||||||
name: build-and-push
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
- high-performance
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
env:
|
|
||||||
DOCKER_HOST: unix:///var/run/docker.sock
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
|
||||||
run: |
|
|
||||||
export DOCKER_HOST=unix:///var/run/docker.sock
|
|
||||||
docker version
|
|
||||||
docker buildx create --use || true
|
|
||||||
docker buildx inspect --bootstrap
|
|
||||||
|
|
||||||
- name: Login to Registry
|
|
||||||
env:
|
|
||||||
REGISTRY_HOSTPORT: ${{ secrets.REGISTRY_HOSTPORT }}
|
|
||||||
REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }}
|
|
||||||
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
|
|
||||||
run: |
|
|
||||||
set -euo pipefail
|
|
||||||
export DOCKER_HOST=unix:///var/run/docker.sock
|
|
||||||
SHA="$(git rev-parse HEAD)"
|
|
||||||
test -n "$REGISTRY_HOSTPORT"
|
|
||||||
echo "$REGISTRY_PASSWORD" | docker login "$REGISTRY_HOSTPORT" -u "$REGISTRY_USERNAME" --password-stdin
|
|
||||||
|
|
||||||
- name: Build and push
|
|
||||||
env:
|
|
||||||
REGISTRY_HOSTPORT: ${{ secrets.REGISTRY_HOSTPORT }}
|
|
||||||
run: |
|
|
||||||
set -euo pipefail
|
|
||||||
export DOCKER_HOST=unix:///var/run/docker.sock
|
|
||||||
SHA="$(git rev-parse HEAD)"
|
|
||||||
docker buildx build --push \
|
|
||||||
-f Dockerfile \
|
|
||||||
-t "$REGISTRY_HOSTPORT/nxtgauge-admin-solid:${SHA}" \
|
|
||||||
-t "$REGISTRY_HOSTPORT/nxtgauge-admin-solid:high-performance-latest" \
|
|
||||||
.
|
|
||||||
|
|
||||||
- name: Prune old image tags (keep latest 1 SHA)
|
|
||||||
if: success()
|
|
||||||
continue-on-error: true
|
|
||||||
env:
|
|
||||||
REGISTRY_HOST: ${{ secrets.REGISTRY_HOSTPORT }}
|
|
||||||
REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }}
|
|
||||||
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
|
|
||||||
run: |
|
|
||||||
set -euo pipefail
|
|
||||||
python3 .forgejo/scripts/registry_prune.py \
|
|
||||||
--registry "$REGISTRY_HOST" \
|
|
||||||
--repo "nxtgauge-admin-solid" \
|
|
||||||
--username "$REGISTRY_USERNAME" \
|
|
||||||
--password "$REGISTRY_PASSWORD" \
|
|
||||||
--keep 1
|
|
||||||
|
|
||||||
- name: Update GitOps and trigger deployment
|
|
||||||
if: success()
|
|
||||||
continue-on-error: true
|
|
||||||
env:
|
|
||||||
GITEOPS_REPO: ${{ secrets.GITEOPS_REPO }}
|
|
||||||
GITEOPS_SSH_KEY: ${{ secrets.GITEOPS_SSH_KEY }}
|
|
||||||
run: |
|
|
||||||
set -euo pipefail
|
|
||||||
SHA="$(git rev-parse HEAD)"
|
|
||||||
|
|
||||||
if [ -z "$GITEOPS_REPO" ]; then
|
|
||||||
echo "GITEOPS_REPO secret not set, skipping GitOps update"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
GITEOPS_DIR=$(mktemp -d)
|
|
||||||
git clone "$GITEOPS_REPO" "$GITEOPS_DIR"
|
|
||||||
cd "$GITEOPS_DIR"
|
|
||||||
|
|
||||||
mkdir -p ~/.ssh
|
|
||||||
echo "$GITEOPS_SSH_KEY" > ~/.ssh/id_ed25519
|
|
||||||
chmod 600 ~/.ssh/id_ed25519
|
|
||||||
ssh-keyscan github.com >> ~/.ssh/known_hosts 2>/dev/null
|
|
||||||
|
|
||||||
python3 .forgejo/scripts/update-gitops.py \
|
|
||||||
--repo "$GITEOPS_DIR" \
|
|
||||||
--service "admin-solid" \
|
|
||||||
--sha "${SHA}" \
|
|
||||||
--message "chore: deploy admin-solid@${SHA}"
|
|
||||||
|
|
||||||
rm -rf "$GITEOPS_DIR"
|
|
||||||
|
|
@ -11,7 +11,7 @@ Usage:
|
||||||
This script:
|
This script:
|
||||||
1. Updates the newTag for the specified service to the SHA
|
1. Updates the newTag for the specified service to the SHA
|
||||||
2. Commits and pushes to the gitops repo
|
2. Commits and pushes to the gitops repo
|
||||||
3. Flux detects the change and deploys
|
3. ArgoCD detects the change and deploys
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
|
|
@ -98,14 +98,10 @@ def main():
|
||||||
image_name = f"nxtgauge-{args.service}"
|
image_name = f"nxtgauge-{args.service}"
|
||||||
|
|
||||||
# Find the right kustomization file based on service
|
# Find the right kustomization file based on service
|
||||||
if "frontend" in args.service:
|
if "frontend" in args.service or "admin" in args.service:
|
||||||
kustomization_path = os.path.join(args.repo, "apps/nxtgauge-frontend-solid/overlays/prod/kustomization.yaml")
|
kustomization_path = os.path.join(args.repo, "apps/nxtgauge-frontend-solid/overlays/prod/kustomization.yaml")
|
||||||
if not os.path.exists(kustomization_path):
|
if not os.path.exists(kustomization_path):
|
||||||
kustomization_path = os.path.join(args.repo, "apps/nxtgauge-frontend-solid/base/kustomization.yaml")
|
kustomization_path = os.path.join(args.repo, "apps/nxtgauge-frontend-solid/base/kustomization.yaml")
|
||||||
elif "admin" in args.service:
|
|
||||||
kustomization_path = os.path.join(args.repo, "apps/nxtgauge-admin-solid/overlays/prod/kustomization.yaml")
|
|
||||||
if not os.path.exists(kustomization_path):
|
|
||||||
kustomization_path = os.path.join(args.repo, "apps/nxtgauge-admin-solid/base/kustomization.yaml")
|
|
||||||
elif "ai-assistant" in args.service:
|
elif "ai-assistant" in args.service:
|
||||||
kustomization_path = os.path.join(args.repo, "apps/nxtgauge-ai-assistant/overlays/prod/kustomization.yaml")
|
kustomization_path = os.path.join(args.repo, "apps/nxtgauge-ai-assistant/overlays/prod/kustomization.yaml")
|
||||||
if not os.path.exists(kustomization_path):
|
if not os.path.exists(kustomization_path):
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
name: Build Admin And Update GitOps
|
name: build-and-push
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
|
|
@ -15,57 +15,79 @@ jobs:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Install Docker CLI
|
- name: Set up Docker Buildx
|
||||||
run: |
|
run: |
|
||||||
apt-get update
|
export DOCKER_HOST=unix:///var/run/docker.sock
|
||||||
apt-get install -y docker.io
|
docker version
|
||||||
|
docker buildx create --use || true
|
||||||
|
docker buildx inspect --bootstrap
|
||||||
|
|
||||||
- name: Log in to registry
|
- name: Login to Registry
|
||||||
run: |
|
|
||||||
echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login registry.nxtgauge.com -u "${{ secrets.REGISTRY_USERNAME }}" --password-stdin
|
|
||||||
|
|
||||||
- name: Build and push admin image
|
|
||||||
run: |
|
|
||||||
set -euo pipefail
|
|
||||||
IMAGE="registry.nxtgauge.com/nxtgauge-admin-solid:${{ github.sha }}"
|
|
||||||
docker build -t "${IMAGE}" -t registry.nxtgauge.com/nxtgauge-admin-solid:latest .
|
|
||||||
docker push "${IMAGE}"
|
|
||||||
docker push registry.nxtgauge.com/nxtgauge-admin-solid:latest
|
|
||||||
|
|
||||||
update-gitops:
|
|
||||||
needs: build
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Update GitOps admin tag
|
|
||||||
env:
|
env:
|
||||||
GITOPS_USERNAME: ${{ secrets.GITOPS_GITHUB_USERNAME || 'Traceworks2023' }}
|
REGISTRY_HOSTPORT: ${{ secrets.REGISTRY_HOSTPORT }}
|
||||||
GITOPS_PASSWORD: ${{ secrets.GITOPS_GITHUB_TOKEN || secrets.GITOPS_PAT }}
|
REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }}
|
||||||
GITOPS_REPO: https://github.com/Traceworks2023/nxtgauge-gitops.git
|
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
|
||||||
IMAGE_TAG: ${{ github.sha }}
|
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
test -n "${GITOPS_PASSWORD:-}" || { echo "GITOPS_PASSWORD is empty"; exit 1; }
|
export DOCKER_HOST=unix:///var/run/docker.sock
|
||||||
AUTH="$(printf '%s' "${GITOPS_USERNAME}:${GITOPS_PASSWORD}" | base64 -w0)"
|
test -n "$REGISTRY_HOSTPORT"
|
||||||
TMP_DIR="$(mktemp -d)"
|
echo "$REGISTRY_PASSWORD" | docker login "$REGISTRY_HOSTPORT" -u "$REGISTRY_USERNAME" --password-stdin
|
||||||
git -c http.extraHeader="AUTHORIZATION: basic ${AUTH}" clone --branch main "${GITOPS_REPO}" "${TMP_DIR}"
|
|
||||||
cd "${TMP_DIR}"
|
- name: Build and push
|
||||||
python3 - <<'PY'
|
env:
|
||||||
from pathlib import Path
|
REGISTRY_HOSTPORT: ${{ secrets.REGISTRY_HOSTPORT }}
|
||||||
import os
|
run: |
|
||||||
path = Path('apps/nxtgauge-admin-solid/overlays/prod/kustomization.yaml')
|
set -euo pipefail
|
||||||
lines = path.read_text().splitlines()
|
export DOCKER_HOST=unix:///var/run/docker.sock
|
||||||
out = []
|
docker buildx build --push \
|
||||||
for line in lines:
|
-f Dockerfile \
|
||||||
if line.strip().startswith('newTag:'):
|
-t "$REGISTRY_HOSTPORT/nxtgauge-admin-solid:${{ gitea.sha }}" \
|
||||||
indent = line[:len(line) - len(line.lstrip())]
|
-t "$REGISTRY_HOSTPORT/nxtgauge-admin-solid:high-performance-latest" \
|
||||||
out.append(f"{indent}newTag: {os.environ['IMAGE_TAG']}")
|
.
|
||||||
else:
|
|
||||||
out.append(line)
|
- name: Prune old image tags (keep latest 1 SHA)
|
||||||
path.write_text('\n'.join(out) + '\n')
|
if: success()
|
||||||
PY
|
continue-on-error: true
|
||||||
git config user.name "forgejo-actions"
|
env:
|
||||||
git config user.email "forgejo-actions@nxtgauge.com"
|
REGISTRY_HOST: ${{ secrets.REGISTRY_HOSTPORT }}
|
||||||
git add apps/nxtgauge-admin-solid/overlays/prod/kustomization.yaml
|
REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }}
|
||||||
git diff --cached --quiet && exit 0
|
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
|
||||||
git commit -m "chore(gitops): update admin image to ${IMAGE_TAG}"
|
run: |
|
||||||
git -c http.extraHeader="AUTHORIZATION: basic ${AUTH}" push origin main
|
set -euo pipefail
|
||||||
|
python3 .gitea/scripts/registry_prune.py \
|
||||||
|
--registry "$REGISTRY_HOST" \
|
||||||
|
--repo "nxtgauge-admin-solid" \
|
||||||
|
--username "$REGISTRY_USERNAME" \
|
||||||
|
--password "$REGISTRY_PASSWORD" \
|
||||||
|
--keep 1
|
||||||
|
|
||||||
|
- name: Update GitOps and trigger deployment
|
||||||
|
if: success()
|
||||||
|
continue-on-error: true
|
||||||
|
env:
|
||||||
|
GITEOPS_REPO: ${{ secrets.GITEOPS_REPO }}
|
||||||
|
GITEOPS_SSH_KEY: ${{ secrets.GITEOPS_SSH_KEY }}
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
if [ -z "$GITEOPS_REPO" ]; then
|
||||||
|
echo "GITEOPS_REPO secret not set, skipping GitOps update"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
GITEOPS_DIR=$(mktemp -d)
|
||||||
|
git clone "$GITEOPS_REPO" "$GITEOPS_DIR"
|
||||||
|
cd "$GITEOPS_DIR"
|
||||||
|
|
||||||
|
mkdir -p ~/.ssh
|
||||||
|
echo "$GITEOPS_SSH_KEY" > ~/.ssh/id_ed25519
|
||||||
|
chmod 600 ~/.ssh/id_ed25519
|
||||||
|
ssh-keyscan github.com >> ~/.ssh/known_hosts 2>/dev/null
|
||||||
|
|
||||||
|
python3 .gitea/scripts/update-gitops.py \
|
||||||
|
--repo "$GITEOPS_DIR" \
|
||||||
|
--service "admin-solid" \
|
||||||
|
--sha "${{ gitea.sha }}" \
|
||||||
|
--message "chore: deploy admin-solid@${{ gitea.sha }}"
|
||||||
|
|
||||||
|
rm -rf "$GITEOPS_DIR"
|
||||||
|
|
|
||||||
40
.github/workflows/sync-to-forgejo.yml
vendored
40
.github/workflows/sync-to-forgejo.yml
vendored
|
|
@ -1,40 +0,0 @@
|
||||||
name: sync-to-forgejo
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
- high-performance
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
sync:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
- name: Push branch to Forgejo
|
|
||||||
env:
|
|
||||||
FORGEJO_SECRET: ${{ secrets.FORGEJO_SECRET || secrets.GITEA_SECRET }}
|
|
||||||
FORGEJO_OWNER: ${{ secrets.FORGEJO_OWNER || 'ashwin' }}
|
|
||||||
FORGEJO_USERNAME: ${{ secrets.FORGEJO_USERNAME || secrets.GITEA_USERNAME || 'ashwin' }}
|
|
||||||
REPO: ${{ github.event.repository.name }}
|
|
||||||
BRANCH: ${{ github.ref_name }}
|
|
||||||
run: |
|
|
||||||
set -euo pipefail
|
|
||||||
test -n "${FORGEJO_SECRET:-}" || { echo "FORGEJO_SECRET is empty"; exit 1; }
|
|
||||||
|
|
||||||
AUTH="$(printf '%s' "${FORGEJO_USERNAME}:${FORGEJO_SECRET}" | base64 -w0)"
|
|
||||||
TARGET="https://ci.nxtgauge.com/${FORGEJO_OWNER}/${REPO}.git"
|
|
||||||
|
|
||||||
git config user.name "github-actions[bot]"
|
|
||||||
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
|
||||||
git remote remove forgejo 2>/dev/null || true
|
|
||||||
git remote add forgejo "${TARGET}"
|
|
||||||
|
|
||||||
git -c http.extraHeader="AUTHORIZATION: basic ${AUTH}" push forgejo "HEAD:${BRANCH}" --force
|
|
||||||
git -c http.extraHeader="AUTHORIZATION: basic ${AUTH}" push forgejo --tags --force
|
|
||||||
46
.github/workflows/sync-to-gitea.yml
vendored
Normal file
46
.github/workflows/sync-to-gitea.yml
vendored
Normal file
|
|
@ -0,0 +1,46 @@
|
||||||
|
name: sync-to-gitea
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- high-performance
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
sync:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Sync to Gitea
|
||||||
|
env:
|
||||||
|
GITEA_TOKEN: ${{ secrets.GITEA_SECRET }}
|
||||||
|
REPO: ${{ github.event.repository.name }}
|
||||||
|
BRANCH: ${{ github.ref_name }}
|
||||||
|
run: |
|
||||||
|
set -euxo pipefail
|
||||||
|
export GIT_TERMINAL_PROMPT=0
|
||||||
|
export GIT_TRACE=1
|
||||||
|
export GIT_CURL_VERBOSE=1
|
||||||
|
|
||||||
|
USER="Admin"
|
||||||
|
TARGET="https://ci.nxtgauge.com/Admin/${REPO}.git"
|
||||||
|
AUTH="$(printf '%s' "${USER}:${GITEA_TOKEN}" | base64 -w0)"
|
||||||
|
|
||||||
|
test -n "${GITEA_TOKEN:-}" || (echo "GITEA_TOKEN empty" && exit 1)
|
||||||
|
curl -fsS -H "Authorization: token ${GITEA_TOKEN}" https://ci.nxtgauge.com/api/v1/user >/dev/null
|
||||||
|
curl -fsS -H "Authorization: Basic ${AUTH}" "${TARGET}/info/refs?service=git-receive-pack" >/dev/null
|
||||||
|
|
||||||
|
git config user.name "github-actions[bot]"
|
||||||
|
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||||
|
git config --global http.version HTTP/1.1
|
||||||
|
git config --global http.postBuffer 524288000
|
||||||
|
git remote remove gitea 2>/dev/null || true
|
||||||
|
git remote add gitea "${TARGET}"
|
||||||
|
|
||||||
|
git -c http.extraheader="Authorization: Basic ${AUTH}" push gitea "HEAD:${BRANCH}" --force
|
||||||
|
git -c http.extraheader="Authorization: Basic ${AUTH}" push gitea --tags --force
|
||||||
|
|
@ -43,4 +43,3 @@ Run additional isolated instances (`9103`, `9104`, ...):
|
||||||
docker run -d --name nxtgauge-admin-solid-9103 -p 9103:9202 nxtgauge-admin-solid:local
|
docker run -d --name nxtgauge-admin-solid-9103 -p 9103:9202 nxtgauge-admin-solid:local
|
||||||
docker run -d --name nxtgauge-admin-solid-9104 -p 9104:9202 nxtgauge-admin-solid:local
|
docker run -d --name nxtgauge-admin-solid-9104 -p 9104:9202 nxtgauge-admin-solid:local
|
||||||
```
|
```
|
||||||
# Mon Jun 8 09:22:40 PM IST 2026
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue