updated #23
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # GitHub Actions CI/CD Pipeline for Cold Email AI | |
| # Triggers on push to main branch and pull requests | |
| name: CI/CD Pipeline | |
| on: | |
| push: | |
| branches: [main, master] | |
| pull_request: | |
| branches: [main, master] | |
| env: | |
| PYTHON_VERSION: "3.11" | |
| jobs: | |
| # ============================================ | |
| # Lint and Type Check | |
| # ============================================ | |
| lint: | |
| name: Lint & Type Check | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ env.PYTHON_VERSION }} | |
| cache: "pip" | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install flake8 black isort | |
| pip install -r requirements.txt | |
| - name: Check code formatting with Black | |
| run: black --check --diff . | |
| continue-on-error: true | |
| - name: Check import sorting with isort | |
| run: isort --check-only --diff . | |
| continue-on-error: true | |
| - name: Lint with flake8 | |
| run: | | |
| # Stop build if there are Python syntax errors or undefined names | |
| flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics | |
| # Exit-zero treats all errors as warnings | |
| flake8 . --count --exit-zero --max-complexity=10 --max-line-length=120 --statistics | |
| # ============================================ | |
| # Build Docker Image | |
| # ============================================ | |
| build: | |
| name: Build Docker Image | |
| runs-on: ubuntu-latest | |
| needs: lint | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build Docker image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| push: false | |
| tags: cold-email-ai:${{ github.sha }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| # ============================================ | |
| # Deploy to Render | |
| # ============================================ | |
| deploy: | |
| name: Deploy to Render | |
| runs-on: ubuntu-latest | |
| needs: build | |
| if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master') | |
| steps: | |
| - name: Deploy to Render | |
| env: | |
| RENDER_DEPLOY_HOOK_URL: ${{ secrets.RENDER_DEPLOY_HOOK_URL }} | |
| run: | | |
| if [ -n "$RENDER_DEPLOY_HOOK_URL" ]; then | |
| curl -X POST "$RENDER_DEPLOY_HOOK_URL" | |
| echo "🚀 Deployment triggered successfully!" | |
| else | |
| echo "⚠️ RENDER_DEPLOY_HOOK_URL secret not set. Skipping deployment." | |
| echo "" | |
| echo "To enable auto-deploy:" | |
| echo "1. Go to Render Dashboard → Your Service → Settings" | |
| echo "2. Copy the Deploy Hook URL" | |
| echo "3. In GitHub: Settings → Secrets → Actions → New secret" | |
| echo "4. Name: RENDER_DEPLOY_HOOK_URL" | |
| echo "5. Value: (paste the Deploy Hook URL)" | |
| fi |