chore: migrate ci naming to forgejo
This commit is contained in:
parent
c7fe1b7ad3
commit
1b1d98ebee
5 changed files with 30 additions and 22 deletions
|
|
@ -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. ArgoCD detects the change and deploys
|
3. Flux detects the change and deploys
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
|
|
@ -98,10 +98,14 @@ 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 or "admin" in args.service:
|
if "frontend" 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):
|
||||||
|
|
@ -46,14 +46,14 @@ jobs:
|
||||||
ALL_SERVICES='gateway,users,companies,jobs,leads,job-seekers,customers,payments,employees,photographers,makeup-artists,tutors,developers,video-editors,graphic-designers,social-media-managers,fitness-trainers,catering-services,ugc-content-creators,cron'
|
ALL_SERVICES='gateway,users,companies,jobs,leads,job-seekers,customers,payments,employees,photographers,makeup-artists,tutors,developers,video-editors,graphic-designers,social-media-managers,fitness-trainers,catering-services,ugc-content-creators,cron'
|
||||||
|
|
||||||
# Force full build for explicit trigger commits.
|
# Force full build for explicit trigger commits.
|
||||||
if echo "$LAST_COMMIT_MSG" | grep -Eiq 'trigger gitea pipeline|force build|rebuild all'; then
|
if echo "$LAST_COMMIT_MSG" | grep -Eiq 'trigger forgejo pipeline|force build|rebuild all'; then
|
||||||
set_output "services_csv" "$ALL_SERVICES"
|
set_output "services_csv" "$ALL_SERVICES"
|
||||||
set_output "has_changes" "true"
|
set_output "has_changes" "true"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Build everything for workflow/docker/shared backend changes.
|
# Build everything for workflow/docker/shared backend changes.
|
||||||
if echo "$CHANGED_FILES" | grep -Eq '^(\.gitea/workflows/|Dockerfile|Dockerfile\.|Cargo\.toml|Cargo\.lock|crates/|scripts/)'; then
|
if echo "$CHANGED_FILES" | grep -Eq '^(\.forgejo/workflows/|Dockerfile|Dockerfile\.|Cargo\.toml|Cargo\.lock|crates/|scripts/)'; then
|
||||||
set_output "services_csv" "$ALL_SERVICES"
|
set_output "services_csv" "$ALL_SERVICES"
|
||||||
set_output "has_changes" "true"
|
set_output "has_changes" "true"
|
||||||
exit 0
|
exit 0
|
||||||
|
|
@ -156,6 +156,7 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
export DOCKER_HOST=unix:///var/run/docker.sock
|
export DOCKER_HOST=unix:///var/run/docker.sock
|
||||||
|
SHA="$(git rev-parse HEAD)"
|
||||||
test -n "$REGISTRY_HOSTPORT"
|
test -n "$REGISTRY_HOSTPORT"
|
||||||
for attempt in 1 2 3 4 5; do
|
for attempt in 1 2 3 4 5; do
|
||||||
echo "Registry login attempt $attempt to $REGISTRY_HOSTPORT"
|
echo "Registry login attempt $attempt to $REGISTRY_HOSTPORT"
|
||||||
|
|
@ -176,6 +177,7 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
export DOCKER_HOST=unix:///var/run/docker.sock
|
export DOCKER_HOST=unix:///var/run/docker.sock
|
||||||
|
SHA="$(git rev-parse HEAD)"
|
||||||
if [ -n "$SERVICES_CSV" ] && ! echo ",$SERVICES_CSV," | grep -q ",${{ matrix.service }},"; then
|
if [ -n "$SERVICES_CSV" ] && ! echo ",$SERVICES_CSV," | grep -q ",${{ matrix.service }},"; then
|
||||||
echo "Skipping unchanged service: ${{ matrix.service }}"
|
echo "Skipping unchanged service: ${{ matrix.service }}"
|
||||||
exit 0
|
exit 0
|
||||||
|
|
@ -187,7 +189,7 @@ jobs:
|
||||||
--build-arg SERVICE_NAME=${{ matrix.service }} \
|
--build-arg SERVICE_NAME=${{ matrix.service }} \
|
||||||
--cache-from type=registry,ref=$REGISTRY_HOSTPORT/nxtgauge-rust-${{ matrix.service }}:buildcache \
|
--cache-from type=registry,ref=$REGISTRY_HOSTPORT/nxtgauge-rust-${{ matrix.service }}:buildcache \
|
||||||
--cache-to type=registry,ref=$REGISTRY_HOSTPORT/nxtgauge-rust-${{ matrix.service }}:buildcache,mode=max \
|
--cache-to type=registry,ref=$REGISTRY_HOSTPORT/nxtgauge-rust-${{ matrix.service }}:buildcache,mode=max \
|
||||||
-t "$REGISTRY_HOSTPORT/nxtgauge-rust-${{ matrix.service }}:${{ gitea.sha }}" \
|
-t "$REGISTRY_HOSTPORT/nxtgauge-rust-${{ matrix.service }}:${SHA}" \
|
||||||
-t "$REGISTRY_HOSTPORT/nxtgauge-rust-${{ matrix.service }}:high-performance-latest" \
|
-t "$REGISTRY_HOSTPORT/nxtgauge-rust-${{ matrix.service }}:high-performance-latest" \
|
||||||
.
|
.
|
||||||
}
|
}
|
||||||
|
|
@ -197,7 +199,7 @@ jobs:
|
||||||
-f Dockerfile.simple \
|
-f Dockerfile.simple \
|
||||||
--build-arg SERVICE_NAME=${{ matrix.service }} \
|
--build-arg SERVICE_NAME=${{ matrix.service }} \
|
||||||
--cache-from type=registry,ref=$REGISTRY_HOSTPORT/nxtgauge-rust-${{ matrix.service }}:buildcache \
|
--cache-from type=registry,ref=$REGISTRY_HOSTPORT/nxtgauge-rust-${{ matrix.service }}:buildcache \
|
||||||
-t "$REGISTRY_HOSTPORT/nxtgauge-rust-${{ matrix.service }}:${{ gitea.sha }}" \
|
-t "$REGISTRY_HOSTPORT/nxtgauge-rust-${{ matrix.service }}:${SHA}" \
|
||||||
-t "$REGISTRY_HOSTPORT/nxtgauge-rust-${{ matrix.service }}:high-performance-latest" \
|
-t "$REGISTRY_HOSTPORT/nxtgauge-rust-${{ matrix.service }}:high-performance-latest" \
|
||||||
.
|
.
|
||||||
}
|
}
|
||||||
|
|
@ -217,7 +219,7 @@ jobs:
|
||||||
docker buildx build --push \
|
docker buildx build --push \
|
||||||
-f Dockerfile.simple \
|
-f Dockerfile.simple \
|
||||||
--build-arg SERVICE_NAME=${{ matrix.service }} \
|
--build-arg SERVICE_NAME=${{ matrix.service }} \
|
||||||
-t "$REGISTRY_HOSTPORT/nxtgauge-rust-${{ matrix.service }}:${{ gitea.sha }}" \
|
-t "$REGISTRY_HOSTPORT/nxtgauge-rust-${{ matrix.service }}:${SHA}" \
|
||||||
-t "$REGISTRY_HOSTPORT/nxtgauge-rust-${{ matrix.service }}:high-performance-latest" \
|
-t "$REGISTRY_HOSTPORT/nxtgauge-rust-${{ matrix.service }}:high-performance-latest" \
|
||||||
.
|
.
|
||||||
fi
|
fi
|
||||||
|
|
@ -231,7 +233,7 @@ jobs:
|
||||||
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
|
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
python3 .gitea/scripts/registry_prune.py \
|
python3 .forgejo/scripts/registry_prune.py \
|
||||||
--registry "$REGISTRY_HOST" \
|
--registry "$REGISTRY_HOST" \
|
||||||
--repo "nxtgauge-rust-${{ matrix.service }}" \
|
--repo "nxtgauge-rust-${{ matrix.service }}" \
|
||||||
--username "$REGISTRY_USERNAME" \
|
--username "$REGISTRY_USERNAME" \
|
||||||
|
|
@ -246,6 +248,7 @@ jobs:
|
||||||
GITEOPS_SSH_KEY: ${{ secrets.GITEOPS_SSH_KEY }}
|
GITEOPS_SSH_KEY: ${{ secrets.GITEOPS_SSH_KEY }}
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
SHA="$(git rev-parse HEAD)"
|
||||||
|
|
||||||
if [ -z "$GITEOPS_REPO" ]; then
|
if [ -z "$GITEOPS_REPO" ]; then
|
||||||
echo "GITEOPS_REPO secret not set, skipping GitOps update"
|
echo "GITEOPS_REPO secret not set, skipping GitOps update"
|
||||||
|
|
@ -264,10 +267,10 @@ jobs:
|
||||||
ssh-keyscan github.com >> ~/.ssh/known_hosts 2>/dev/null
|
ssh-keyscan github.com >> ~/.ssh/known_hosts 2>/dev/null
|
||||||
|
|
||||||
# Update gitops with new SHA
|
# Update gitops with new SHA
|
||||||
python3 .gitea/scripts/update-gitops.py \
|
python3 .forgejo/scripts/update-gitops.py \
|
||||||
--repo "$GITEOPS_DIR" \
|
--repo "$GITEOPS_DIR" \
|
||||||
--service "${{ matrix.service }}" \
|
--service "${{ matrix.service }}" \
|
||||||
--sha "${{ gitea.sha }}" \
|
--sha "${SHA}" \
|
||||||
--message "chore: deploy ${{ matrix.service }}@${{ gitea.sha }}"
|
--message "chore: deploy ${{ matrix.service }}@${SHA}"
|
||||||
|
|
||||||
rm -rf "$GITEOPS_DIR"
|
rm -rf "$GITEOPS_DIR"
|
||||||
|
|
@ -1,8 +1,9 @@
|
||||||
name: sync-to-gitea
|
name: sync-to-forgejo
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
|
- main
|
||||||
- high-performance
|
- high-performance
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
|
@ -16,9 +17,9 @@ jobs:
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Sync to Gitea
|
- name: Sync to Forgejo
|
||||||
env:
|
env:
|
||||||
GITEA_TOKEN: ${{ secrets.GITEA_SECRET }}
|
FORGEJO_TOKEN: ${{ secrets.FORGEJO_SECRET }}
|
||||||
REPO: ${{ github.event.repository.name }}
|
REPO: ${{ github.event.repository.name }}
|
||||||
BRANCH: ${{ github.ref_name }}
|
BRANCH: ${{ github.ref_name }}
|
||||||
run: |
|
run: |
|
||||||
|
|
@ -29,18 +30,18 @@ jobs:
|
||||||
|
|
||||||
USER="Admin"
|
USER="Admin"
|
||||||
TARGET="https://ci.nxtgauge.com/Admin/${REPO}.git"
|
TARGET="https://ci.nxtgauge.com/Admin/${REPO}.git"
|
||||||
AUTH="$(printf '%s' "${USER}:${GITEA_TOKEN}" | base64 -w0)"
|
AUTH="$(printf '%s' "${USER}:${FORGEJO_TOKEN}" | base64 -w0)"
|
||||||
|
|
||||||
test -n "${GITEA_TOKEN:-}" || (echo "GITEA_TOKEN empty" && exit 1)
|
test -n "${FORGEJO_TOKEN:-}" || (echo "FORGEJO_TOKEN empty" && exit 1)
|
||||||
curl -fsS -H "Authorization: token ${GITEA_TOKEN}" https://ci.nxtgauge.com/api/v1/user >/dev/null
|
curl -fsS -H "Authorization: token ${FORGEJO_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
|
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.name "github-actions[bot]"
|
||||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||||
git config --global http.version HTTP/1.1
|
git config --global http.version HTTP/1.1
|
||||||
git config --global http.postBuffer 524288000
|
git config --global http.postBuffer 524288000
|
||||||
git remote remove gitea 2>/dev/null || true
|
git remote remove forgejo 2>/dev/null || true
|
||||||
git remote add gitea "${TARGET}"
|
git remote add forgejo "${TARGET}"
|
||||||
|
|
||||||
git -c http.extraheader="Authorization: Basic ${AUTH}" push gitea "HEAD:${BRANCH}" --force
|
git -c http.extraheader="Authorization: Basic ${AUTH}" push forgejo "HEAD:${BRANCH}" --force
|
||||||
git -c http.extraheader="Authorization: Basic ${AUTH}" push gitea --tags --force
|
git -c http.extraheader="Authorization: Basic ${AUTH}" push forgejo --tags --force
|
||||||
|
|
@ -23,4 +23,4 @@ Required secrets:
|
||||||
- `REGISTRY_USERNAME`
|
- `REGISTRY_USERNAME`
|
||||||
- `REGISTRY_PASSWORD`
|
- `REGISTRY_PASSWORD`
|
||||||
|
|
||||||
See `.gitea/workflows/README.md` for details.
|
See `.forgejo/workflows/README.md` for details.
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue