Skip to content
GitHub

GitHub Actions CI/CD Pipeline အခြေခံသဘောတရားများ

CI/CD သည် ခေတ်မီ Software Engineering ၏ အခြေခံ အုတ်မြစ်ဖြစ်ပြီး အပိုင်းနှစ်ပိုင်း ပါဝင်ပါတယ်:

graph LR
subgraph CI["🔄 Continuous Integration (CI)"]
Commit["Git Push / PR"] --> Lint["Lint & Typecheck"]
Lint --> Test["Unit & E2E Tests"]
Test --> Build["Production Build"]
end
subgraph CD["🚀 Continuous Deployment (CD)"]
Build --> Deploy["Auto Deploy to Cloud VPS"]
end
  1. Continuous Integration (CI): Developer များ Code push လုပ်တိုင်း Unit Tests များ၊ Linter များနှင့် Build များကို Cloud Runner ပေါ်တွင် အလိုအလျောက် စစ်ဆေးပြီး Error ရှိက ချက်ချင်း Alert ပေးခြင်း။
  2. Continuous Deployment (CD): စစ်ဆေးမှု အားလုံး အောင်မြင်ပါက Production Server ပေါ်သို့ လူမပါဘဲ အလိုအလျောက် တိုက်ရိုက် Deploy တင်ပေးခြင်း။

GitHub Actions ၏ အဓိက အစိတ်အပိုင်း ၅ ခု

Section titled “GitHub Actions ၏ အဓိက အစိတ်အပိုင်း ၅ ခု”

GitHub Actions သည် Repository ထဲရှိ .github/workflows/*.yml ဖိုင်များဖြင့် အလုပ်လုပ်ပါတယ်:

အစိတ်အပိုင်းအဓိပ္ပာယ်ဥပမာ
1. Event (on:)Workflow ကို စတင် အစပျိုးပေးသော လှုပ်ရှားမှုpush: branches: [main], pull_request
2. JobRunner တစ်ခုတည်းပေါ်တွင် အတူတကွ Run မည့် Steps အစုအဝေးjobs: test:, jobs: build:
3. RunnerGitHub မှ ပေးထားသော Virtual Machine (VM)runs-on: ubuntu-latest
4. StepJob တစ်ခုအတွင်း အစဉ်လိုက် လုပ်ဆောင်မည့် Task တစ်ခုချင်းစီRun script သို့မဟုတ် Pre-built Action
5. ActionCommunity မှ ဖန်တီးထားသော ပြန်သုံးနိုင်သည့် Reusable Toolactions/checkout@v4, actions/setup-node@v4

ပထမဆုံး CI Workflow ဖိုင် ရေးဆွဲခြင်း (.github/workflows/ci.yml)

Section titled “ပထမဆုံး CI Workflow ဖိုင် ရေးဆွဲခြင်း (.github/workflows/ci.yml)”

မိမိ Project ၏ Root folder တွင် .github/workflows/ci.yml ဖိုင် ဆောက်ပြီး အောက်ပါအတိုင်း ရေးပါ:

name: Continuous Integration (CI)
# main branch သို့ push လုပ်တိုင်း သို့မဟုတ် PR ဖွင့်တိုင်း Run မည်
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
test-and-build:
name: Run Linter, Tests and Build
runs-on: ubuntu-latest
steps:
# 1. Repository မှ Code များကို Runner ထဲသို့ ဆွဲယူမည်
- name: Checkout Source Code
uses: actions/checkout@v4
# 2. Node.js Environment တပ်ဆင်မည် (with NPM Cache for Speed)
- name: Setup Node.js 22
uses: actions/setup-node@v4
with:
node-version: 22
cache: "npm"
# 3. Dependencies များ သွင်းမည်
- name: Install Dependencies
run: npm ci
# 4. TypeScript Type Checking ပြုလုပ်မည်
- name: Run Type Check
run: npm run typecheck
continue-on-error: false
# 5. Automated Tests များ စစ်ဆေးမည်
- name: Run Tests
run: npm test
# 6. Production Build အောင်မအောင် စစ်ဆေးမည်
- name: Build Application
run: npm run build

GitHub Actions ၏ စွမ်းဆောင်ရည် မြှင့်တင်နည်းများ

Section titled “GitHub Actions ၏ စွမ်းဆောင်ရည် မြှင့်တင်နည်းများ”
  1. npm ci vs npm install: CI Server များတွင် npm install မသုံးဘဲ package-lock.json အတိုင်း တိကျစွာ သွင်းပေးသည့် npm ci ကိုသာ သုံးရပါမည် (ပိုမိုမြန်ဆန်ပြီး Consistent ဖြစ်စေပါသည်)။
  2. Dependency Caching: actions/setup-nodecache: 'npm' option သည် node_modules cache ကို သိမ်းဆည်းထားသဖြင့် Build time ကို မိနစ်ပိုင်းမှ စက္ကန့်ပိုင်းအထိ လျှော့ချပေးပါတယ်။

🎯 သင်ခန်းစာ အနှစ်ချုပ် Checklist

Section titled “🎯 သင်ခန်းစာ အနှစ်ချုပ် Checklist”
  • .github/workflows/ folder အောက်တွင် YAML ဖိုင်များ ထားရှိပါ။
  • Pull Request တိုင်းတွင် Test များနှင့် Build များကို CI ဖြင့် အလိုအလျောက် စစ်ဆေးပါ။
  • CI အောင်မြင်မှသာ Main branch သို့ Merge ခွင့်ပြုသည့် Branch Protection Rules များ သတ်မှတ်ပါ။
📖

ဒီသင်ခန်းစာ ဖတ်ပြီးပြီလား?

ပြီးမြောက်ကြောင်း မှတ်သားထားရန် အောက်ပါ ခလုတ်ကို နှိပ်ပါ