Cách mình setup CI/CD đơn giản với GitHub Actions
Description and use
Simple CI/CD workflow for Node.js on GitHub Actions: tests, lint, build, SSH deployment, and automated releases.
Problem
Thiết lập CI/CD đơn giản cho dự án Node.js trên GitHub Actions, bao gồm chạy test, lint, deploy, và release.
Outcome
Pipeline tự động chạy test, lint, build, deploy và release, giảm thiểu lỗi thủ công và tăng tốc độ phát triển.
Workflow
- Checkout mã nguồn
- Cài đặt Node.js (v20) và cache npm
- Chạy npm ci, test, lint
- Deploy tới server qua SSH khi branch main
- Chạy test trên nhiều phiên bản Node (18,20,22)
- Cache node_modules để tăng tốc build
- Chạy workflow khi có tag release và tạo release
Evidence
GitHub Actions miễn phí cho public repo và có 2000 phút/tháng cho private repo.
Deploy to server via SSH using appleboy/ssh-action
Create Release using softprops/action-gh-release
- Record date: 2026-09-22T17:45:44.017Z