Files
evrak/AI-Text/Example-CICD.md
gitmuhammedalbayrak cf05dbe943
Some checks failed
Build and Deploy / build-push (push) Has been cancelled
chore: Update project dependencies.
2025-11-24 02:40:51 +03:00

2.8 KiB

Reference CI/CD Pipeline Configuration

This is a working example of a Gitea Actions workflow used in the current production environment. It demonstrates the setup for Docker builds and Kubernetes deployments on an ARM64 architecture.

name: Map Build and Deploy run-name: ${{ gitea.actor }} Map Build and Deploy 🚀 on: [push]

jobs: build-and-deploy: runs-on: ubuntu-latest

# ⚠️ SOLUTION: REMOVING DOCKER_HOST ENV SETTING! 
# The runner will establish the TCP connection automatically via its internal mechanism (Your stable setting).

steps:
  - name: Checkout Code
    uses: actions/checkout@v3

  # -----------------------------------------------------------------
  # CI PART
  # -----------------------------------------------------------------
  - name: Setup Docker Buildx
    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 STEP: Capture image digest as output
  - name: Docker Build and 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 PART (Final Solution)
  # -----------------------------------------------------------------
  - name: Install Kubectl Binary
    # Installs ARM64 compatible kubectl
    run: |
      curl -LO "[https://dl.k8s.io/release/$(curl](https://dl.k8s.io/release/$(curl) -L -s [https://dl.k8s.io/release/stable.txt)/bin/linux/arm64/kubectl](https://dl.k8s.io/release/stable.txt)/bin/linux/arm64/kubectl)"
      chmod +x kubectl
      sudo mv kubectl /usr/local/bin/

  - name: Deploy to Kubernetes and Update
    run: |
      # 1. Write Kubeconfig content to file
      echo "${{ secrets.KUBE_CONFIG }}" > /tmp/kubeconfig.yaml
      
      # 2. Get the new image Digest
      NEW_IMAGE_DIGEST="git.konstantiniyye.studio/gitea_admin/dogu@${{ steps.docker_build.outputs.digest }}"

      # 3. Update Deployment skipping TLS verification (Rancher Self-Signed Fix)
      # NOTE: If you added insecure-skip-tls-verify: true to your Kubeconfig, these lines will work.
      kubectl set image deployment/dogu-haritasi web=${NEW_IMAGE_DIGEST} \
        --kubeconfig=/tmp/kubeconfig.yaml -n default
        
      kubectl rollout restart deployment/dogu-haritasi \
        --kubeconfig=/tmp/kubeconfig.yaml -n default