TL;DR

GitHub Actions Runner là ứng dụng thi hành công việc CI/CD trên GitHub, có 2 triển khai:

  • GitHub-hosted runners: Quản lý bởi GitHub, ephemeral, 99.9% SLA, tích hợp sẵn công cụ (Docker, GitHub CLI)
  • Self-hosted runners: Chạy trên server riêng, linh hoạt cao, tùy biến toàn bộ, phù hợp tuân thủ + hardware tùy chỉnh

Kiến trúc nội bộ gồm Listener (polling API mỗi 50 giây) và Worker (thi hành job). Tối ưu đúng cách (caching, shallow clone, parallelization) giảm 50%+ thời gian build. Enterprise nhận 50,000 phút miễn phí/tháng. So với Jenkins (1,800 plugins), CircleCI (advanced caching), GitLab CI (self-managed), GitHub Actions là default cho teams native GitHub.

Vấn Đề Runner Giải Quyết

Trước khi CI/CD tự động hóa, developers phải thực hiện thủ công: chạy build, chạy test, deploy. GitHub Actions Runner tự động hóa toàn bộ quy trình từ commit → deploy, giải phóng developer tập trung viết code.

Nhưng chọn mô hình runner sai lại tạo ra vấn đề khác:

  • GitHub-hosted thiếu kiểm soát: Không thể custom hardware (GPU, metal), không thể chạy on-premises, cold start delay từ 30 giây
  • Self-hosted quá phức tạp: Quản lý scaling, cập nhật, security, caching — nếu không làm đúng sẽ chậm hơn GitHub-hosted
  • Compliance chặt: Cần air-gap network, data residency riêng — GitHub-hosted không đáp ứng

GitHub Actions Runner giải quyết bằng 2 mô hình chọn lọc: 80% teams dùng GitHub-hosted (zero hassle), 20% dùng self-hosted + Actions Runner Controller (ARC) để Kubernetes-scale.

Kiến Trúc: Listener & Worker

GitHub Actions Runner architecture
Runner có 2 thành phần: Listener (polling), Worker (executing)

Runner được viết bằng C# (fork cũ từ Azure Pipelines Agent). Đang di chuyển từ Azure DevOps API → GitHub Actions Broker API (2 năm, cơ chế không đổi nhưng API thay đổi).

Listener (luôn chạy):

  • Đăng ký runner với GitHub API (JIT config)
  • Polling broker service mỗi 50 giây để hỏi: "Có job nào cho tôi không?"
  • Nếu có job message → acquire job (2 phút timeout)
  • Chạy background task renew job lock mỗi phút (extend lock đến 10 phút tương lai)
  • Nếu không renew → server cancel job tự động

Worker (spawn khi job đến):

  • Nhận job instructions từ Listener
  • Thi hành job commands (build, test, deploy)
  • Report log + result trở lại GitHub

Flow này dạo này không đổi, nhưng API format & response headers đã migrate hoàn toàn sang cái mới.

GitHub-Hosted vs Self-Hosted: Chọn Cái Nào?

GitHub-hosted vs self-hosted runners
Hai mô hình runner có tradeoff khác nhau

GitHub-hosted runners:

  • ✅ Zero setup, auto-update, ephemeral (reimage sau mỗi job)
  • ✅ 24/7 support, 99.9% SLA (Microsoft data center)
  • ✅ Pre-installed tools: Docker, GitHub CLI, mọi runtime phổ biến
  • ✅ Không tính network egress (huge cost saver với large docker images)
  • ✅ Unlimited Docker Hub pulls (partnership Docker)
  • ❌ Cold start ~1 phút (provision VM)
  • ❌ SaaS-only, không on-premises
  • ❌ Concurrency limits ở scale cao

Self-hosted runners:

  • ✅ Custom hardware (GPU, metal, ARM)
  • ✅ On-premises, air-gap network, data residency
  • ✅ Không cold start (runner đã chạy)
  • ✅ Custom labels → route job đến machine specific (ví dụ: label gpu chỉ chạy trên machine có GPU)
  • ❌ Full responsibility: scaling, security, caching, updates
  • ❌ Version lock: >30 days behind → cannot connect GitHub Enterprise Cloud
  • ❌ ARC (Actions Runner Controller) chỉ support Linux (Kubernetes)
  • ❌ macOS: max 2 VMs per physical machine, không container runtime
  • ❌ Windows: containers slow startup, cần custom orchestrator
  • ❌ Total cost of ownership thường cao hơn GitHub-hosted khi tính staff time

Khuyến cáo: 80% trường hợp dùng GitHub-hosted. Self-hosted chỉ khi: (1) GitHub Enterprise Server, (2) core business = infrastructure/Kubernetes, (3) strict compliance.

Tối Ưu Performance: Từ 18 Phút Xuống 7 Phút

Performance optimization techniques
4 kỹ thuật chính giảm 50%+ thời gian workflow

Workflows thường chậm dần theo thời gian project lớn. Nhưng hầu hết chậm do cách viết sai, không phải giới hạn GitHub Actions.

Benchmark tối ưu:

  • Dependency caching: npm/pip cache theo package-lock hash → tiết kiệm 2-5 phút/job
  • Shallow clone: fetch-depth: 1 với repo lớn → tiết kiệm 30s-2 phút
  • Job parallelization: Chạy lint, test, build song song → 50%+ faster tổng thể
  • Matrix optimization: Tránh test combination dư thừa, chỉ test critical paths

Real case: 10-dev team, 50 builds/day, 18 phút/build = 150 giờ đợi/tháng. Sau tối ưu xuống 7 phút = khôi phục 92 giờ productive time/tháng.

So Sánh với CI/CD Khác: Jenkins, CircleCI, GitLab CI

Jenkins:

  • Open-source, 1,800+ plugins, tùy biến sâu
  • Infrastructure-agnostic, hybrid environments
  • Nhưng: manual setup/maintenance, curves đ learning suptó, không cloud-native
  • Phù hợp: teams legacy/complex workflows

CircleCI:

  • Cloud-native, advanced caching & test splitting
  • Real-time dashboards, performance insights chi tiết
  • Self-hosted option, cloud + hybrid
  • Nhưng: credit-based billing (parallelism = cost), tight learning
  • Phù hợp: teams muốn performance optimization built-in

GitLab CI/CD:

  • Native tích hợp GitLab platform (merge requests, issues)
  • Fully self-managed on-prem option
  • KHÔNG context switching như external tools
  • Nhưng: lock-in vào GitLab ecosystem, team size cost scaling
  • Phù hợp: teams already using GitLab VCS

GitHub Actions (Runner):

  • Tight GitHub integration (zero vendors), marketplace actions khổng lồ
  • Generous free minutes (public repos)
  • Straightforward YAML workflows, ramp-up nhanh
  • Nhưng: ít tùy biến system-level so Jenkins, SaaS-only cho hosted
  • Phù hợp: 80% teams (code on GitHub, straightforward pipelines)

Hạn Chế & Pricing

GitHub-Hosted Limitations:

  • Cold start delay (VM provision)
  • Concurrency limits ở scale cao
  • SaaS-only (no on-prem option)

GitHub-Hosted Pricing:

  • Pay-as-you-go, no upfront commitments
  • Free minutes: public repos unlimited + 50k/month (Enterprise)
  • Zero network egress, unlimited Docker Hub pulls = hidden savings

Self-Hosted Pricing:

  • Direct VM cost thấp hơn GitHub-hosted thoạt tiên
  • Nhưng: staff time (troubleshooting, scaling, security), storage, networking → TCO thường cao hơn

Roadmap & Tương Lai

GitHub không nhận open-source contributions vào runner codebase nữa (kể từ Aug 2025). Cộng đồng suy đoán C# runner cũ có thể sắp EOL + new architecture coming.

What's next: GitHub Agentic Workflows (technical preview) — AI coding agents natively trong GitHub Actions để handle issue triage, docs updates, code quality improvements. Platform đang pivot từ execution-focused → AI-driven automation.

Khi Nào Dùng GitHub Actions Runner?

  • ✅ Code already on GitHub + straightforward CI/CD (build, test, deploy)
  • ✅ Teams muốn zero infrastructure overhead
  • ✅ Public projects (free generous minutes)
  • ✅ Không cần custom hardware hoặc on-prem compliance
  • ❌ Không dùng nếu: need 1,800+ plugin ecosystem (Jenkins), need Kubernetes-native (Argo), locked vào Gitlab

Kết

GitHub Actions Runner là ứng dụng nhỏ nhưng mạnh mẽ — default tốt cho phần lớn teams. 2 loại runner (GitHub-hosted + self-hosted) cung cấp spectrum từ "zero setup" → "full control". Kiến trúc Listener-Worker đơn giản nhưng đủ cho hàng triệu jobs/ngày.

Nếu bạn:

  • Code trên GitHub + pipeline straightforward → GitHub-hosted là lựa chọn
  • Cần custom hardware, compliance strict → self-hosted + ARC
  • Cần 1,800 plugins hoặc Kubernetes-native → Jenkins hay Argo Workflows

Runner ecosystem sắp thay đổi với AI agentic workflows — tools sắp không chỉ execute mà còn suggest, triage, improve code tự động. Lúc đó GitHub Actions sẽ từ "CI/CD tool" thành "DevOps AI platform".

Via: GitHub Actions Runner — Repository, GitHub Actions Documentation, Depot — Runner Architecture