mirror of
https://github.com/nethunterzist/trendyol-analiz
synced 2026-06-30 17:17:02 +00:00
ci(k8s): Gitea K8s pipeline ekle — CiroMarket K8s migration
Ne yaptık: - .gitea/workflows/deploy-backend.yaml — Gitea Actions ile backend image'ı build et, Gitea registry'e push et, ci-cd repo manifest'ini bump'la - .gitea/workflows/deploy-frontend.yaml — Frontend'i VITE_API_URL=https://trendyol-api.194.187.253.61.sslip.io ile build et, aynı pattern - .github/workflows/deploy.yml — sync-gitea job eklendi: GitHub push sonrası Gitea mirror sync + deploy-backend/frontend.yaml dispatch Neden yaptık: - CiroMarket'i Coolify'dan K8s'e taşıma projesi - Coolify pipeline parallel çalışmaya devam ediyor (zero downtime) - GitHub push → Gitea mirror → Gitea Actions → Gitea registry → ArgoCD → K8s rolling update zinciri tamamlandı
This commit is contained in:
77
.gitea/workflows/deploy-backend.yaml
Normal file
77
.gitea/workflows/deploy-backend.yaml
Normal file
@@ -0,0 +1,77 @@
|
||||
name: ciromarket-backend-build-and-deploy
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
paths:
|
||||
- 'backend/**'
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
REGISTRY: git.novasis.tr
|
||||
IMAGE: admin/trendyol-analiz/backend
|
||||
DOCKER_HOST: tcp://172.17.0.1:2375
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Compute tag
|
||||
id: tag
|
||||
run: echo "sha=${GITHUB_SHA::7}" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Pre-build disk check
|
||||
run: |
|
||||
df -h /var/lib/docker || df -h /
|
||||
docker system df || true
|
||||
|
||||
- name: Login to Gitea registry
|
||||
run: echo "${{ secrets.REGISTRY_TOKEN }}" | docker login "$REGISTRY" -u admin --password-stdin
|
||||
|
||||
- name: Build & push image
|
||||
run: |
|
||||
docker build \
|
||||
--file backend/Dockerfile \
|
||||
--tag "$REGISTRY/$IMAGE:${{ steps.tag.outputs.sha }}" \
|
||||
--tag "$REGISTRY/$IMAGE:latest" \
|
||||
.
|
||||
docker push "$REGISTRY/$IMAGE:${{ steps.tag.outputs.sha }}"
|
||||
docker push "$REGISTRY/$IMAGE:latest"
|
||||
|
||||
- name: Bump deployment manifest in ci-cd repo
|
||||
run: |
|
||||
set -euo pipefail
|
||||
git clone https://gitea_admin:${{ secrets.CI_CD_TOKEN }}@git.novasis.tr/gitea_admin/ci-cd.git /tmp/ci-cd
|
||||
cd /tmp/ci-cd
|
||||
git config user.email "ci@novasis.tr"
|
||||
git config user.name "gitea-actions-bot"
|
||||
MANIFEST="apps/ciromarket/backend/deploy/deployment.yaml"
|
||||
MAX=5
|
||||
for i in $(seq 1 $MAX); do
|
||||
git fetch origin main
|
||||
git reset --hard origin/main
|
||||
sed -i -E "s|image: ${REGISTRY}/${IMAGE}:.*|image: ${REGISTRY}/${IMAGE}:${{ steps.tag.outputs.sha }}|" "$MANIFEST"
|
||||
if git diff --quiet "$MANIFEST"; then
|
||||
echo "No image change to commit."
|
||||
exit 0
|
||||
fi
|
||||
git add "$MANIFEST"
|
||||
git commit -m "ci: bump ciromarket/backend to ${{ steps.tag.outputs.sha }} [skip ci]"
|
||||
if git push origin main; then
|
||||
echo "Pushed on attempt $i"
|
||||
exit 0
|
||||
fi
|
||||
sleep 3
|
||||
done
|
||||
exit 1
|
||||
|
||||
- name: Post-build cleanup
|
||||
if: always()
|
||||
run: |
|
||||
docker buildx prune --force --keep-storage 3GB 2>&1 | tail -3 || true
|
||||
docker image prune -f 2>&1 | tail -2 || true
|
||||
78
.gitea/workflows/deploy-frontend.yaml
Normal file
78
.gitea/workflows/deploy-frontend.yaml
Normal file
@@ -0,0 +1,78 @@
|
||||
name: ciromarket-frontend-build-and-deploy
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
paths:
|
||||
- 'admin-panel/**'
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
REGISTRY: git.novasis.tr
|
||||
IMAGE: admin/trendyol-analiz/frontend
|
||||
DOCKER_HOST: tcp://172.17.0.1:2375
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Compute tag
|
||||
id: tag
|
||||
run: echo "sha=${GITHUB_SHA::7}" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Pre-build disk check
|
||||
run: |
|
||||
df -h /var/lib/docker || df -h /
|
||||
docker system df || true
|
||||
|
||||
- name: Login to Gitea registry
|
||||
run: echo "${{ secrets.REGISTRY_TOKEN }}" | docker login "$REGISTRY" -u admin --password-stdin
|
||||
|
||||
- name: Build & push image
|
||||
run: |
|
||||
docker build \
|
||||
--file admin-panel/Dockerfile \
|
||||
--build-arg VITE_API_URL=https://trendyol-api.194.187.253.61.sslip.io \
|
||||
--tag "$REGISTRY/$IMAGE:${{ steps.tag.outputs.sha }}" \
|
||||
--tag "$REGISTRY/$IMAGE:latest" \
|
||||
./admin-panel
|
||||
docker push "$REGISTRY/$IMAGE:${{ steps.tag.outputs.sha }}"
|
||||
docker push "$REGISTRY/$IMAGE:latest"
|
||||
|
||||
- name: Bump deployment manifest in ci-cd repo
|
||||
run: |
|
||||
set -euo pipefail
|
||||
git clone https://gitea_admin:${{ secrets.CI_CD_TOKEN }}@git.novasis.tr/gitea_admin/ci-cd.git /tmp/ci-cd
|
||||
cd /tmp/ci-cd
|
||||
git config user.email "ci@novasis.tr"
|
||||
git config user.name "gitea-actions-bot"
|
||||
MANIFEST="apps/ciromarket/frontend/deploy/deployment.yaml"
|
||||
MAX=5
|
||||
for i in $(seq 1 $MAX); do
|
||||
git fetch origin main
|
||||
git reset --hard origin/main
|
||||
sed -i -E "s|image: ${REGISTRY}/${IMAGE}:.*|image: ${REGISTRY}/${IMAGE}:${{ steps.tag.outputs.sha }}|" "$MANIFEST"
|
||||
if git diff --quiet "$MANIFEST"; then
|
||||
echo "No image change to commit."
|
||||
exit 0
|
||||
fi
|
||||
git add "$MANIFEST"
|
||||
git commit -m "ci: bump ciromarket/frontend to ${{ steps.tag.outputs.sha }} [skip ci]"
|
||||
if git push origin main; then
|
||||
echo "Pushed on attempt $i"
|
||||
exit 0
|
||||
fi
|
||||
sleep 3
|
||||
done
|
||||
exit 1
|
||||
|
||||
- name: Post-build cleanup
|
||||
if: always()
|
||||
run: |
|
||||
docker buildx prune --force --keep-storage 3GB 2>&1 | tail -3 || true
|
||||
docker image prune -f 2>&1 | tail -2 || true
|
||||
50
.github/workflows/deploy.yml
vendored
50
.github/workflows/deploy.yml
vendored
@@ -4,6 +4,9 @@ name: Deploy
|
||||
# Zincir: validate → build-push (backend+frontend) → deploy → verify
|
||||
# Trendyol-analiz tertemiz auto-deploy — SellerX deploy-frontend.yml pattern'i
|
||||
# ─────────────────────────────────────────────────────────────────────────────
|
||||
# K8s pipeline (Gitea mirror → Gitea Actions → Gitea registry → ArgoCD) parallel
|
||||
# çalışır — Coolify pipeline'ı DURDURMAZ.
|
||||
# ─────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
on:
|
||||
push:
|
||||
@@ -18,6 +21,53 @@ env:
|
||||
NODE_VERSION: '20'
|
||||
|
||||
jobs:
|
||||
# ───────────────────────────────────────────────────────────────────────────
|
||||
# K8s MIRROR SYNC — Coolify pipeline'dan BAĞIMSIZ, validate ile PARALEL.
|
||||
# GitHub push → Gitea mirror sync → Gitea Actions → Gitea registry → ArgoCD
|
||||
# Başarısız olursa Coolify pipeline DURMUYOR.
|
||||
# ───────────────────────────────────────────────────────────────────────────
|
||||
sync-gitea:
|
||||
name: Sync Gitea Mirror (K8s Pipeline)
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Trigger Gitea mirror sync
|
||||
run: |
|
||||
HTTP=$(curl -s -o /dev/null -w "%{http_code}" \
|
||||
-X POST "https://git.novasis.tr/api/v1/repos/admin/trendyol-analiz/mirror-sync" \
|
||||
-H "Authorization: token ${{ secrets.GITEA_MIRROR_TOKEN }}")
|
||||
echo "Mirror sync HTTP: $HTTP"
|
||||
if [ "$HTTP" -ge 400 ]; then
|
||||
echo "Mirror sync failed (HTTP $HTTP) — K8s pipeline delayed, Coolify unaffected"
|
||||
exit 0
|
||||
fi
|
||||
echo "Mirror sync triggered — waiting 30s for sync to complete..."
|
||||
sleep 30
|
||||
|
||||
- name: Dispatch Gitea Actions build (deploy-backend.yaml)
|
||||
run: |
|
||||
HTTP=$(curl -s -o /dev/null -w "%{http_code}" \
|
||||
-X POST "https://git.novasis.tr/api/v1/repos/admin/trendyol-analiz/actions/workflows/deploy-backend.yaml/dispatches" \
|
||||
-H "Authorization: token ${{ secrets.GITEA_MIRROR_TOKEN }}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"ref":"main"}')
|
||||
echo "Gitea backend dispatch HTTP: $HTTP"
|
||||
if [ "$HTTP" -ge 400 ]; then
|
||||
echo "Gitea backend dispatch failed — trigger manually"
|
||||
fi
|
||||
|
||||
- name: Dispatch Gitea Actions build (deploy-frontend.yaml)
|
||||
run: |
|
||||
HTTP=$(curl -s -o /dev/null -w "%{http_code}" \
|
||||
-X POST "https://git.novasis.tr/api/v1/repos/admin/trendyol-analiz/actions/workflows/deploy-frontend.yaml/dispatches" \
|
||||
-H "Authorization: token ${{ secrets.GITEA_MIRROR_TOKEN }}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"ref":"main"}')
|
||||
echo "Gitea frontend dispatch HTTP: $HTTP"
|
||||
if [ "$HTTP" -ge 400 ]; then
|
||||
echo "Gitea frontend dispatch failed — trigger manually"
|
||||
fi
|
||||
|
||||
|
||||
# ───────────────────────────────────────────────────────────────────────────
|
||||
# ADIM 1a — Backend hızlı sağlık testi (pytest)
|
||||
# ───────────────────────────────────────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user