Appearance
Triển khai Git
Hướng dẫn đưa monorepo core lên Git (GitLab) và quy trình làm việc hằng ngày.
1. Khởi tạo remote (lần đầu)
Repo đã có lịch sử local trên nhánh main. Tạo project trống trên GitLab rồi:
bash
git remote add origin git@gitlab.tasco.vn:frontend/framework-core.git
git push -u origin main
mainlà nhánh release. Đừng force-push lênmain.
2. Branch model (trunk-based)
main ────●────●────●────●───▶ (luôn xanh, là nguồn release)
\ /
feat/* ●──●──● (nhánh ngắn, merge qua MR)- Nhánh tính năng:
feat/<scope>, sửa lỗi:fix/<scope>, tài liệu:docs/<scope>. - Nhánh ngắn ngày, rebase theo
mainthường xuyên, merge qua Merge Request. - Không commit thẳng lên
main.
bash
git switch -c feat/use-table-filters
# ... code ...
pnpm lint && pnpm typecheck && pnpm build
pnpm changeset # nếu có đổi package
git push -u origin feat/use-table-filters
# mở Merge Request trên GitLab3. Commit convention
Dùng Conventional Commits: feat:, fix:, docs:, chore:, refactor:, test:. Scope theo package: feat(ui): ..., fix(composables): ....
Conventional Commits là cho lịch sử git. Bump version + changelog do Changesets quyết định (xem Release). Mỗi MR đổi package bắt buộc kèm một changeset.
4. Bảo vệ nhánh main (GitLab settings)
- Settings → Repository → Protected branches:
main= Maintainers push, no force-push. - Settings → Merge requests: bật Pipelines must succeed + All threads resolved.
- Yêu cầu tối thiểu 1 approval cho MR.
5. CI/CD variables
Settings → CI/CD → Variables:
| Biến | Giá trị | Ghi chú |
|---|---|---|
NPM_TOKEN | token registry @tasco | Masked, Protected (chỉ nhánh/tag protected) |
.gitlab-ci.yml (root) đã ghi token vào .npmrc trong before_script và chạy:
quality(mọi nhánh): lint → typecheck → build.release(chỉmain):changeset publish.
6. Quy trình release
bash
# 1) Trên main đã gom đủ changeset → bump version + changelog:
git switch -c chore/version-packages
pnpm changeset version # cập nhật version (lockstep) + CHANGELOG
git commit -am "chore: version packages"
git push -u origin chore/version-packages
# 2) Merge MR này vào main → CI job `release` tự `changeset publish`.Tag nên gắn theo version (Changesets/CI có thể tạo @tasco/...@x.y.z). Channel beta/next: xem Release.
7. Repo team sản phẩm (riêng biệt)
Mỗi sản phẩm là repo riêng, không clone monorepo core:
bash
npx @tasco/cli tasco-orders # đã có .gitlab-ci.yml + .npmrc
cd tasco-orders && git init && git add -A && git commit -m "chore: init"
git remote add origin git@gitlab.tasco.vn:product/tasco-orders.git
git push -u origin mainCI của team sản phẩm cũng cần biến NPM_TOKEN để cài @tasco/* từ registry.
8. .gitignore
Đã loại trừ node_modules, dist, .nuxt, .output, .turbo, storybook-static, .vitepress/cache, .env* (giữ .env.example). Không commit secrets.