1. Apa itu CI/CD dan Mengapa Krusial?
**Continuous Integration (CI)** adalah praktik di mana setiap developer secara rutin menggabungkan perubahan kode ke repositori sentral, di mana setiap push atau Pull Request secara otomatis diverifikasi oleh automated tests dan linter. **Continuous Deployment (CD)** adalah proses otomatis yang merilis kode yang telah lolos pengujian langsung ke lingkungan staging atau production.
2. Struktur Workflow GitHub Actions
File konfigurasi CI/CD diletakkan di folder `.github/workflows/ci.yml`. Formatnya menggunakan YAML yang memuat events (kapan alur dijalankan), jobs (tugas yang dijalankan secara paralel atau sekuensial), dan steps (perintah individual).
| 1 | name: CI Pipeline |
| 2 | |
| 3 | on: |
| 4 | push: |
| 5 | branches: [main] |
| 6 | pull_request: |
| 7 | branches: [main] |
| 8 | |
| 9 | jobs: |
| 10 | verify: |
| 11 | runs-on: ubuntu-latest |
| 12 | steps: |
| 13 | - name: Checkout Code |
| 14 | uses: actions/checkout@v4 |
| 15 | |
| 16 | - name: Setup Node.js |
| 17 | uses: actions/setup-node@v4 |
| 18 | with: |
| 19 | node-version: 20 |
| 20 | cache: 'pnpm' |
| 21 | |
| 22 | - name: Install Dependencies |
| 23 | run: pnpm install --frozen-lockfile |
| 24 | |
| 25 | - name: Run Type Check & Lint |
| 26 | run: | |
| 27 | pnpm tsc --noEmit |
| 28 | pnpm lint |
| 29 | |
| 30 | - name: Run Automated Unit Tests |
| 31 | run: pnpm test |
3. Keamanan: Environment Secrets vs Public Variables
**Jangan pernah menulis kredensial atau password database di dalam file workflow atau git repo!** Selalu gunakan **Repository Secrets** di GitHub (`${{ secrets.DATABASE_URL }}`). Nilai ini dienkripsi oleh GitHub dan otomatis disamarkan (*masked*) pada log eksekusi build.