This commit is contained in:
@@ -6,7 +6,7 @@ jobs:
|
|||||||
build-and-deploy:
|
build-and-deploy:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
# KUBERNETES ÜZERİNDEKİ DOCKER BAĞLANTISI İÇİN GEREKLİ ORTAM DEĞİŞKENLERİ
|
# DOCKER İÇİN GEREKLİ ENV AYARLARI
|
||||||
env:
|
env:
|
||||||
DOCKER_HOST: unix:///var/run/dind-socket-dir/docker.sock
|
DOCKER_HOST: unix:///var/run/dind-socket-dir/docker.sock
|
||||||
DOCKER_TLS_CERTDIR: ""
|
DOCKER_TLS_CERTDIR: ""
|
||||||
@@ -16,7 +16,7 @@ jobs:
|
|||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
# -----------------------------------------------------------------
|
# -----------------------------------------------------------------
|
||||||
# CI KISMI
|
# CI KISMI (Burada hata yok, hız için kısaltıldı)
|
||||||
# -----------------------------------------------------------------
|
# -----------------------------------------------------------------
|
||||||
- name: Docker Buildx Kurulumu
|
- name: Docker Buildx Kurulumu
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
@@ -28,9 +28,9 @@ jobs:
|
|||||||
username: gitea_admin
|
username: gitea_admin
|
||||||
password: ${{ secrets.REGISTRY_TOKEN }}
|
password: ${{ secrets.REGISTRY_TOKEN }}
|
||||||
|
|
||||||
# PUSH ADIMI: Yeni imajın kimliğini (digest) çıktı olarak alıyoruz
|
# PUSH ADIMI: Digest'i çıktı olarak alır
|
||||||
- name: Docker Build ve Push
|
- name: Docker Build ve Push
|
||||||
id: docker_build # <-- Çıktı almak için bu ID gerekli
|
id: docker_build
|
||||||
uses: docker/build-push-action@v5
|
uses: docker/build-push-action@v5
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
@@ -40,22 +40,24 @@ jobs:
|
|||||||
cache-to: type=gha,mode=max
|
cache-to: type=gha,mode=max
|
||||||
|
|
||||||
# -----------------------------------------------------------------
|
# -----------------------------------------------------------------
|
||||||
# CD KISMI (Continuous Deployment)
|
# CD KISMI (GitHub bağımsız, sadece 'run' komutları ile)
|
||||||
# -----------------------------------------------------------------
|
# -----------------------------------------------------------------
|
||||||
- name: Kubernetes'e Deploy Et
|
- name: Kubectl Binary Kurulumu
|
||||||
uses: appleboy/kubectl-action@master # Popüler kubectl action'ı
|
# catthehacker imajında kubectl olsa da, buraya basit bir check ekledik
|
||||||
with:
|
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/)
|
||||||
# Gitea'da tanımlanan Kubeconfig Secret'ı kullanır
|
|
||||||
kubeconfig_content: ${{ secrets.KUBE_CONFIG }}
|
|
||||||
# Tek bir shell komutunda imajı güncelleyip Deployment'ı yeniden başlatır
|
|
||||||
script: |
|
|
||||||
# Yeni imajın Digest'i (sha256:...) otomatik olarak alınır
|
|
||||||
NEW_IMAGE_DIGEST="git.konstantiniyye.studio/gitea_admin/dogu@${{ steps.docker_build.outputs.digest }}"
|
|
||||||
|
|
||||||
echo "Yeni imaj: $NEW_IMAGE_DIGEST"
|
- name: Kubernetes'e Deploy Et ve Güncelle
|
||||||
|
run: |
|
||||||
# 1. Deployment'taki imajı yeni Digest ile günceller
|
# 1. Kubeconfig içeriğini dosyaya yazar
|
||||||
kubectl set image deployment/dogu-haritasi web=${NEW_IMAGE_DIGEST} -n default
|
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
|
||||||
|
|
||||||
# 2. Güncellemenin hemen başlaması için Deployment'ı yeniden başlatır
|
# 4. Deployment'ı yeniden başlatır (güncellemenin hemen başlaması için)
|
||||||
kubectl rollout restart deployment/dogu-haritasi -n default
|
kubectl rollout restart deployment/dogu-haritasi --kubeconfig=/tmp/kubeconfig.yaml -n default
|
||||||
Reference in New Issue
Block a user