Spaces:
Running on CPU Upgrade
Running on CPU Upgrade
| name: CI/CD Pipeline | |
| # ส่วนที่ 1: กำหนดเหตุการณ์ (Event) ที่จะให้ Workflow เริ่มทำงาน | |
| on: | |
| push: | |
| branches: [ main, master ] | |
| pull_request: | |
| branches: [ main, master ] | |
| jobs: | |
| # ส่วนที่ 2: Continuous Integration (CI) - การทดสอบและตรวจสอบคุณภาพโค้ด | |
| test: | |
| runs-on: ubuntu-latest | |
| # กำหนดค่า Environment Variables สำหรับตอนรัน Test | |
| # ใส่เครื่องหมายคำพูด (Quotes) ครอบค่าไว้เพื่อป้องกัน Error ของ YAML Syntax | |
| env: | |
| DATABASE_URL: "sqlite+aiosqlite:///:memory:" | |
| SECRET_KEY: "test_secret_key_for_ci" | |
| ALGORITHM: "HS256" | |
| R2_BUCKET_NAME: "test-bucket" | |
| R2_ACCOUNT_ID: "test-id" | |
| R2_ACCESS_KEY: "test-key" | |
| R2_SECRET_KEY: "test-secret" | |
| HF: "test-hf-token" | |
| REDIS_URL: "redis://localhost:6379/0" | |
| GMAIL: "test@gmail.com" | |
| BREVO_API_KEY: "test-brevo-key" | |
| PROJECT_NAME: "FaceSearchTest" | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install uv | |
| run: curl -LsSf https://astral.sh/uv/install.sh | sh | |
| - name: Set up Python | |
| run: uv python install 3.11 | |
| - name: Install dependencies | |
| run: uv sync --frozen | |
| - name: Run Pytest | |
| run: uv run pytest tests | |
| # ส่วนที่ 3: Continuous Deployment (CD) - การนำไปใช้งาน (ตัวอย่าง) | |
| deploy: | |
| needs: test | |
| if: github.event_name == 'push' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Deploy Status | |
| run: | | |
| echo "🎉 All tests passed successfully!" | |
| echo "🚀 Deployment process would start here." | |
| echo "Branch: ${{ github.ref }}" | |