1. 14:43 13/10/2026
## Tổng quan
Việc tự động hóa xây dựng, kiểm thử và triển khai cho cả ứng dụng web (React, Vue, Next.js) và ứng dụng di động (React Native, Flutter, native iOS/Android) giúp nhóm phát triển giảm thiểu lỗi thủ công và rút ngắn chu kỳ phát hành. GitHub Actions cung cấp máy chủ chạy miễn phí, trong khi Fastlane là công cụ chuẩn cho quy trình ký, tải lên App Store Connect và Google Play Console.
## Kiến trúc pipeline đề xuất
- **Trigger**: push vào nhánh `main` hoặc tạo pull request.
- **Job `lint-test`**: chạy ESLint, Prettier, unit test (Jest/Vitest) cho cả web và mobile trong cùng một matrix.
- **Job `build-web`**: cài đặt Node, chạy `npm ci && npm run build`, upload artifact `dist/` để deploy sau.
- **Job `build-ios`**: chạy trên `macos-latest`, cài CocoaPods, `fastlane ios build` tạo `.ipa`.
- **Job `build-android`**: chạy trên `ubuntu-latest`, `fastlane android build` tạo `.aab`.
- **Job `deploy`**: chỉ chạy khi các job trước thành công và là tag `v*`. Deploy web lên Vercel/Netlify, upload `.ipa` lên TestFlight, `.aab` lên Play Console internal track.
## Ví dụ cấu hình GitHub Actions (đơn giản hóa)
```yaml
name: CI/CD Multi‑Platform
on:
push:
branches: [main]
pull_request:
workflow_dispatch:
jobs:
lint-test:
runs-on: ubuntu-latest
strategy:
matrix:
node: [20]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
- run: npm ci
- run: npm run lint
- run: npm test -- --ci
build-web:
needs: lint-test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm ci && npm run build
- uses: actions/upload-artifact@v4
with:
name: web-dist
path: dist/
build-ios:
needs: lint-test
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: 3.2
- run: bundle install
- run: bundle exec fastlane ios build
- uses: actions/upload-artifact@v4
with:
name: ios-ipa
path: ./fastlane/builds/*.ipa
build-android:
needs: lint-test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17
- run: bundle install
- run: bundle exec fastlane android build
- uses: actions/upload-artifact@v4
with:
name: android-aab
path: ./fastlane/builds/*.aab
deploy:
needs: [build-web, build-ios, build-android]
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
name: web-dist
path: ./dist
- run: npx vercel --prod --token=${{ secrets.VERCEL_TOKEN }}
- uses: actions/download-artifact@v4
with:
name: ios-ipa
path: ./ios
- run: fastlane pilot upload ipa:./ios/*.ipa
- uses: actions/download-artifact@v4
with:
name: android-aab
path: ./android
- run: fastlane supply upload --aab ./android/*.aab --track internal
```
## Lời khuyên thực tế
- **Cache dependencies**: dùng `actions/cache` cho `node_modules`, `Pods`, `gradle` để giảm thời gian chạy.
- **Matrix strategy**: chạy song song lint/test trên nhiều phiên bản Node để phát hiện sớm sự không tương thích.
- **Secrets management**: lưu khóa ký iOS (`MATCH_PASSWORD`), khóa Google Play (`PLAY_JSON_KEY`) trong GitHub Secrets, không bao giờ commit.
- **Fastlane lanes tách biệt**: `build`, `beta`, `release` để dễ dàng mở rộng sau này.
- **Monitoring**: bật Slack/Teams notification qua `actions/github-script` khi pipeline thất bại.
Với cấu trúc này,团队 có thể phát hành đồng bộ web và mobile chỉ bằng một lệnh `git push origin v1.2.3`, đảm bảo tính nhất quán và giảm thiểu rủi ro triển khai.