|
| 1 | +name: Deploy to RunPod |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + paths: |
| 8 | + - 'src/**' |
| 9 | + - 'python-validator/**' |
| 10 | + - 'Dockerfile.serverless' |
| 11 | + - 'package.json' |
| 12 | + - '.github/workflows/deploy-runpod.yml' |
| 13 | + workflow_dispatch: |
| 14 | + inputs: |
| 15 | + force_deploy: |
| 16 | + description: 'Force deployment even if tests fail' |
| 17 | + required: false |
| 18 | + default: 'false' |
| 19 | + |
| 20 | +env: |
| 21 | + REGISTRY: ghcr.io |
| 22 | + IMAGE_NAME_AGENTS: ${{ github.repository }}/ai-agents |
| 23 | + IMAGE_NAME_VALIDATOR: ${{ github.repository }}/json-validator |
| 24 | + |
| 25 | +jobs: |
| 26 | + build-and-push-agents: |
| 27 | + name: Build & Push Node.js Agents Image |
| 28 | + runs-on: ubuntu-latest |
| 29 | + permissions: |
| 30 | + contents: read |
| 31 | + packages: write |
| 32 | + |
| 33 | + steps: |
| 34 | + - name: Checkout code |
| 35 | + uses: actions/checkout@v4 |
| 36 | + |
| 37 | + - name: Set up Docker Buildx |
| 38 | + uses: docker/setup-buildx-action@v3 |
| 39 | + with: |
| 40 | + platforms: linux/amd64 |
| 41 | + |
| 42 | + - name: Log in to GitHub Container Registry |
| 43 | + uses: docker/login-action@v3 |
| 44 | + with: |
| 45 | + registry: ${{ env.REGISTRY }} |
| 46 | + username: ${{ github.actor }} |
| 47 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 48 | + |
| 49 | + - name: Extract metadata |
| 50 | + id: meta |
| 51 | + uses: docker/metadata-action@v5 |
| 52 | + with: |
| 53 | + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_AGENTS }} |
| 54 | + tags: | |
| 55 | + type=ref,event=branch |
| 56 | + type=ref,event=pr |
| 57 | + type=semver,pattern={{version}} |
| 58 | + type=semver,pattern={{major}}.{{minor}} |
| 59 | + type=sha,prefix={{branch}}- |
| 60 | + type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }} |
| 61 | +
|
| 62 | + - name: Build and push Docker image (AMD64 only) |
| 63 | + uses: docker/build-push-action@v5 |
| 64 | + env: |
| 65 | + VCS_REF: ${{ github.sha }} |
| 66 | + with: |
| 67 | + context: . |
| 68 | + file: ./Dockerfile.serverless |
| 69 | + platforms: linux/amd64 |
| 70 | + push: true |
| 71 | + tags: ${{ steps.meta.outputs.tags }} |
| 72 | + labels: ${{ steps.meta.outputs.labels }} |
| 73 | + cache-from: type=gha |
| 74 | + cache-to: type=gha,mode=max |
| 75 | + |
| 76 | + - name: Image digest |
| 77 | + run: echo ${{ steps.meta.outputs.digest }} |
| 78 | + |
| 79 | + build-and-push-validator: |
| 80 | + name: Build & Push Python Validator Image |
| 81 | + runs-on: ubuntu-latest |
| 82 | + permissions: |
| 83 | + contents: read |
| 84 | + packages: write |
| 85 | + |
| 86 | + steps: |
| 87 | + - name: Checkout code |
| 88 | + uses: actions/checkout@v4 |
| 89 | + |
| 90 | + - name: Set up Docker Buildx |
| 91 | + uses: docker/setup-buildx-action@v3 |
| 92 | + with: |
| 93 | + platforms: linux/amd64 |
| 94 | + |
| 95 | + - name: Log in to GitHub Container Registry |
| 96 | + uses: docker/login-action@v3 |
| 97 | + with: |
| 98 | + registry: ${{ env.REGISTRY }} |
| 99 | + username: ${{ github.actor }} |
| 100 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 101 | + |
| 102 | + - name: Extract metadata |
| 103 | + id: meta |
| 104 | + uses: docker/metadata-action@v5 |
| 105 | + with: |
| 106 | + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_VALIDATOR }} |
| 107 | + tags: | |
| 108 | + type=ref,event=branch |
| 109 | + type=ref,event=pr |
| 110 | + type=semver,pattern={{version}} |
| 111 | + type=semver,pattern={{major}}.{{minor}} |
| 112 | + type=sha,prefix={{branch}}- |
| 113 | + type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }} |
| 114 | +
|
| 115 | + - name: Build and push Docker image (AMD64 only) |
| 116 | + uses: docker/build-push-action@v5 |
| 117 | + env: |
| 118 | + VCS_REF: ${{ github.sha }} |
| 119 | + with: |
| 120 | + context: ./python-validator |
| 121 | + file: ./python-validator/Dockerfile.serverless |
| 122 | + platforms: linux/amd64 |
| 123 | + push: true |
| 124 | + tags: ${{ steps.meta.outputs.tags }} |
| 125 | + labels: ${{ steps.meta.outputs.labels }} |
| 126 | + cache-from: type=gha |
| 127 | + cache-to: type=gha,mode=max |
| 128 | + |
| 129 | + - name: Image digest |
| 130 | + run: echo ${{ steps.meta.outputs.digest }} |
| 131 | + |
| 132 | + deploy-notification: |
| 133 | + name: Deployment Notification |
| 134 | + runs-on: ubuntu-latest |
| 135 | + needs: [build-and-push-agents, build-and-push-validator] |
| 136 | + if: always() |
| 137 | + |
| 138 | + steps: |
| 139 | + - name: Check deployment status |
| 140 | + env: |
| 141 | + AGENTS_RESULT: ${{ needs.build-and-push-agents.result }} |
| 142 | + VALIDATOR_RESULT: ${{ needs.build-and-push-validator.result }} |
| 143 | + AGENTS_IMAGE: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_AGENTS }} |
| 144 | + VALIDATOR_IMAGE: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_VALIDATOR }} |
| 145 | + run: | |
| 146 | + if [ "$AGENTS_RESULT" == "success" ] && [ "$VALIDATOR_RESULT" == "success" ]; then |
| 147 | + echo "✅ All images built and pushed successfully!" |
| 148 | + echo "🚀 Ready to deploy to RunPod" |
| 149 | + echo "" |
| 150 | + echo "Agent Image: ${AGENTS_IMAGE}:latest" |
| 151 | + echo "Validator Image: ${VALIDATOR_IMAGE}:latest" |
| 152 | + else |
| 153 | + echo "❌ Deployment failed - check logs above" |
| 154 | + exit 1 |
| 155 | + fi |
| 156 | +
|
| 157 | + - name: RunPod Deployment Instructions |
| 158 | + if: success() |
| 159 | + env: |
| 160 | + AGENTS_IMAGE: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_AGENTS }} |
| 161 | + run: | |
| 162 | + echo "📋 RunPod Deployment Steps:" |
| 163 | + echo "1. Go to RunPod Serverless Dashboard" |
| 164 | + echo "2. Create new template with image: ${AGENTS_IMAGE}:latest" |
| 165 | + echo "3. Configure environment variables:" |
| 166 | + echo " - ANTHROPIC_API_KEY" |
| 167 | + echo " - DASHSCOPE_API_KEY" |
| 168 | + echo " - DEEPSEEK_API_KEY" |
| 169 | + echo " - PYTHON_VALIDATOR_URL=http://validator:8001" |
| 170 | + echo "4. Set auto-scaling: Min=0, Max=10" |
| 171 | + echo "5. Enable FlashBoot for fast cold starts" |
| 172 | + echo "6. Deploy validator service separately" |
0 commit comments