হোম/Roadmap/Chapter 3.02
Phase 3 · Chapter 3.02

GitHub Actions for ML

Free, integrated, marketplace-rich — GitHub Actions ML team-এর default CI/CD platform। একটা YAML, পুরো automation।

Why GitHub Actions

কেন এটাই প্রথম পছন্দ

  • Repo-র সাথে native integration — extra setup নেই।
  • Marketplace-এ setup-python, docker/build-push-action ready।
  • Public repo-তে free, private-তেও generous minutes।
  • Matrix builds — Python 3.10/3.11/3.12 একসাথে test।
Anatomy

Workflow file structure

.github/workflows/ml-ci.yml — 3 key concept:

  • Trigger: on: [push, pull_request] — কখন চলবে।
  • Job: এক বা একাধিক — parallel বা sequential।
  • Step: Shell command বা reusable action
Workflow 1

Lint + Test on every PR

yamlproduction
name: ML CI
on:
  push:
    branches: [main]
  pull_request:

jobs:
  test:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        python: ["3.11", "3.12"]
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with:
          python-version: ${{ matrix.python }}
          cache: pip
      - run: pip install -r requirements.txt
      - run: ruff check src/
      - run: pytest -v --cov=src tests/
      - run: python scripts/validate_model.py
        env:
          MIN_ACCURACY: "0.85"
Workflow 2

Build + Push Docker image to GHCR

yamlproduction
name: Build Image
on:
  push:
    tags: ["v*"]

jobs:
  build:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      packages: write
    steps:
      - uses: actions/checkout@v4
      - uses: docker/setup-buildx-action@v3
      - uses: docker/login-action@v3
        with:
          registry: ghcr.io
          username: ${{ github.actor }}
          password: ${{ secrets.GITHUB_TOKEN }}
      - uses: docker/build-push-action@v6
        with:
          context: .
          push: true
          tags: |
            ghcr.io/${{ github.repository }}/iris-api:latest
            ghcr.io/${{ github.repository }}/iris-api:${{ github.ref_name }}
          cache-from: type=gha
          cache-to: type=gha,mode=max
Pro Tips

Speed + safety

  • cache: pip use করো — dependency install 5x faster।
  • concurrency group দাও — same PR-এ duplicate run cancel হবে।
  • Heavy training step-এ self-hosted GPU runner ব্যবহার করো।
  • Secret সবসময় secrets.* থেকে — কখনো hardcode না।
Common Mistakes

যা ভুল হয়

  • Test job-এ continue-on-error: true — failure লুকিয়ে যায়।
  • Tag push না করে :latest overwrite — rollback অসম্ভব।
  • Workflow-এ raw token print — log-এ leak।
Mini Project

তোমার project-এ যোগ করো

  1. .github/workflows/ml-ci.yml তৈরি করো (Workflow 1)।
  2. Iris FastAPI service-এর জন্য Workflow 2 চালু করো।
  3. PR খুলে দেখো — green check আসছে কিনা।
Takeaway

মনে রাখো

GitHub Actions = YAML + marketplace + secrets। এই তিনটা mastery করলে যেকোনো ML pipeline automate করা সম্ভব।