remove embeddings from feed processing, move CSV appending to finally… #164
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
| name: Deploy Backend | |
| # This workflow builds, pushes to ECR, deploys to ECS, and cleans up old images | |
| # It keeps the 5 most recent images to save storage costs while maintaining rollback capability | |
| on: | |
| push: | |
| branches: [ main ] | |
| paths: | |
| - 'backend/**' | |
| - '.github/workflows/deploy-backend.yml' | |
| jobs: | |
| build-push-and-redeploy: | |
| name: Build, Push to ECR, Deploy to ECS, and Cleanup Old Images | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| env: | |
| AWS_REGION: us-east-2 | |
| ECR_REGISTRY: 058264255918.dkr.ecr.us-east-2.amazonaws.com | |
| ECR_REPOSITORY: bug-free-octo-spork/backend | |
| IMAGE_TAG: latest | |
| ECS_CLUSTER: bug-free-octo-spork-django-cluster | |
| ECS_SERVICE_NAME: bug-free-octo-spork-django-task-service-i1pnpewj | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Configure AWS credentials | |
| uses: aws-actions/configure-aws-credentials@v4 | |
| with: | |
| aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
| aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| aws-region: ${{ env.AWS_REGION }} | |
| - name: Login to Amazon ECR | |
| id: login-ecr | |
| uses: aws-actions/amazon-ecr-login@v2 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build Docker image | |
| run: | | |
| IMAGE_URI=${ECR_REGISTRY}/${ECR_REPOSITORY}:${IMAGE_TAG} | |
| echo "Building ${IMAGE_URI} for ARM64" | |
| docker buildx build --platform linux/arm64 -f backend/Dockerfile -t ${IMAGE_URI} --load backend | |
| - name: Push Docker image | |
| run: | | |
| IMAGE_URI=${ECR_REGISTRY}/${ECR_REPOSITORY}:${IMAGE_TAG} | |
| docker push ${IMAGE_URI} | |
| - name: Force new deployment on ECS service | |
| run: | | |
| aws ecs update-service \ | |
| --cluster "${ECS_CLUSTER}" \ | |
| --service "${ECS_SERVICE_NAME}" \ | |
| --force-new-deployment \ | |
| --region "${AWS_REGION}" | |
| - name: Clean up old ECR images | |
| run: | | |
| echo "🧹 Cleaning up old ECR images..." | |
| # Delete all images except the latest 3 | |
| aws ecr describe-images \ | |
| --repository-name "${ECR_REPOSITORY}" \ | |
| --region "${AWS_REGION}" \ | |
| --query 'sort_by(imageDetails, &imagePushedAt)[3:][].imageDigest' \ | |
| --output text | \ | |
| xargs -I {} aws ecr batch-delete-image \ | |
| --repository-name "${ECR_REPOSITORY}" \ | |
| --region "${AWS_REGION}" \ | |
| --image-ids imageDigest={} || echo "No old images to delete" | |
| echo "✅ Cleanup complete" | |