Khi bạn push code lên remote (Git server) thì pipeline (CI/CD) sẽ chạy theo flow chuẩn như sau:


1️⃣ Developer push code

Ví dụ:

git add .
git commit -m "update feature"
git push origin main

Code được đẩy lên remote như:

  • GitHub
  • GitLab
  • Bitbucket

2️⃣ Webhook kích hoạt CI/CD

Remote repo có cấu hình CI/CD:

  • GitHub Actions
  • GitLab CI/CD
  • Jenkins

Khi nhận được push event → hệ thống tạo 1 pipeline run mới.


3️⃣ Runner/Agent nhận job

Pipeline không tự chạy.

Nó cần:

  • Runner (GitLab Runner)
  • GitHub Runner
  • Jenkins Agent

Runner có thể nằm:

  • Trên VPS
  • Trên máy local
  • Trong Docker
  • Kubernetes cluster

4️⃣ Pipeline đọc file config

Ví dụ:

PlatformFile cấu hình
GitHub.github/workflows/*.yml
GitLab.gitlab-ci.yml
JenkinsJenkinsfile

Ví dụ pipeline thường gồm:

stages:
  - build
  - test
  - deploy

5️⃣ Các stage chạy tuần tự hoặc song song

Ví dụ thực tế:

🔹 Build

  • Composer install
  • npm install
  • Build assets

🔹 Test

  • PHPUnit
  • ESLint
  • Static analysis

🔹 Deploy

  • SSH lên server
  • Docker build
  • Rsync code
  • Kubernetes rollout

6️⃣ Kết quả

  • ✅ Success → deploy xong
  • ❌ Fail → dừng tại stage lỗi

Bạn có thể:

  • Xem log realtime
  • Retry job
  • Approve manual deploy

🧠 Ví dụ thực tế với hệ thống của bạn

Vì bạn hay dùng:

  • WordPress
  • CI3
  • Nginx
  • VPS Ubuntu

Pipeline thường sẽ:

Push main
→ Run test
→ Build assets
→ SSH vào VPS
→ git pull
→ clear cache
→ reload php-fpm

Hoặc nếu xịn hơn:

Push
→ Build Docker image
→ Push lên registry
→ Server pull image mới
→ Zero-downtime deploy

⚡ Tóm lại bản chất

Push → Trigger webhook → CI server tạo pipeline → Runner chạy script → Deploy