63 lines
2.6 KiB
YAML
63 lines
2.6 KiB
YAML
name: Harita Build ve Deploy
|
||
run-name: ${{ gitea.actor }} Harita Build ve Deploy 🚀
|
||
on: [push]
|
||
|
||
jobs:
|
||
build-and-deploy:
|
||
runs-on: ubuntu-latest
|
||
|
||
# DOCKER İÇİN GEREKLİ ENV AYARLARI
|
||
env:
|
||
DOCKER_HOST: unix:///var/run/dind-socket-dir/docker.sock
|
||
DOCKER_TLS_CERTDIR: ""
|
||
|
||
steps:
|
||
- name: Kodu Çek (Checkout)
|
||
uses: actions/checkout@v3
|
||
|
||
# -----------------------------------------------------------------
|
||
# CI KISMI (Burada hata yok, hız için kısaltıldı)
|
||
# -----------------------------------------------------------------
|
||
- name: Docker Buildx Kurulumu
|
||
uses: docker/setup-buildx-action@v3
|
||
|
||
- name: Docker Login (Gitea Registry)
|
||
uses: docker/login-action@v3
|
||
with:
|
||
registry: git.konstantiniyye.studio
|
||
username: gitea_admin
|
||
password: ${{ secrets.REGISTRY_TOKEN }}
|
||
|
||
# PUSH ADIMI: Digest'i çıktı olarak alır
|
||
- name: Docker Build ve Push
|
||
id: docker_build
|
||
uses: docker/build-push-action@v5
|
||
with:
|
||
context: .
|
||
push: true
|
||
tags: git.konstantiniyye.studio/gitea_admin/dogu:latest
|
||
cache-from: type=gha
|
||
cache-to: type=gha,mode=max
|
||
|
||
# -----------------------------------------------------------------
|
||
# CD KISMI (GitHub bağımsız, sadece 'run' komutları ile)
|
||
# -----------------------------------------------------------------
|
||
- name: Kubectl Binary Kurulumu
|
||
# catthehacker imajında kubectl olsa da, buraya basit bir check ekledik
|
||
run: which kubectl || (echo "Kubectl bulunamadi, kuruluyor..." && curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/arm64/kubectl" && chmod +x kubectl && sudo mv kubectl /usr/local/bin/)
|
||
|
||
- name: Kubernetes'e Deploy Et ve Güncelle
|
||
run: |
|
||
# 1. Kubeconfig içeriğini dosyaya yazar
|
||
echo "${{ secrets.KUBE_CONFIG }}" > /tmp/kubeconfig.yaml
|
||
|
||
# 2. Yeni imaj Digest'ini alır
|
||
NEW_IMAGE_DIGEST="git.konstantiniyye.studio/gitea_admin/dogu@${{ steps.docker_build.outputs.digest }}"
|
||
|
||
echo "Deployment imajı güncelleniyor: $NEW_IMAGE_DIGEST"
|
||
|
||
# 3. Deployment'ı günceller
|
||
kubectl set image deployment/dogu-haritasi web=${NEW_IMAGE_DIGEST} --kubeconfig=/tmp/kubeconfig.yaml -n default
|
||
|
||
# 4. Deployment'ı yeniden başlatır (güncellemenin hemen başlaması için)
|
||
kubectl rollout restart deployment/dogu-haritasi --kubeconfig=/tmp/kubeconfig.yaml -n default |