Skip to content

Merge remote-tracking branch 'origin/main' into main #24

Merge remote-tracking branch 'origin/main' into main

Merge remote-tracking branch 'origin/main' into main #24

Workflow file for this run

name: Build and Push Docker Image to AWS ECR
on:
push:
branches:
- main
paths:
- '.github/workflows/cf-ai-agent.yml'
- 'dodao-ai-agents/crowd-fund-analysis/**'
jobs:
build-and-push:
name: Build and Push Docker Image
runs-on: ubuntu-latest
env:
NODE_OPTIONS: --max-old-space-size=8182
AWS_REGION: us-east-1 # Change this to the AWS region where your ECR repository is located
ECR_REPOSITORY: crowd-fund-analysis # Replace this with your ECR repository name
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Build Docker Image
working-directory: dodao-ai-agents/crowd-fund-analysis
run: |
IMAGE_TAG=${{ github.sha }}
GIT_COMMIT_HASH=$(git rev-parse HEAD)
GIT_COMMIT_MESSAGE=$(git log -1 --pretty=%B)
docker build --build-arg GIT_COMMIT_HASH=$GIT_COMMIT_HASH --build-arg GIT_COMMIT_MESSAGE="$GIT_COMMIT_MESSAGE" -t ${{ steps.login-ecr.outputs.registry }}/${{ env.ECR_REPOSITORY }}:$IMAGE_TAG .
- name: Tag Docker Image
working-directory: dodao-ai-agents/crowd-fund-analysis
run: |
IMAGE_TAG=${{ github.sha }}
docker tag ${{ steps.login-ecr.outputs.registry }}/${{ env.ECR_REPOSITORY }}:$IMAGE_TAG ${{ steps.login-ecr.outputs.registry }}/${{ env.ECR_REPOSITORY }}:latest
- name: Push Docker Image
working-directory: dodao-ai-agents/crowd-fund-analysis
run: |
IMAGE_TAG=${{ github.sha }}
docker push ${{ steps.login-ecr.outputs.registry }}/${{ env.ECR_REPOSITORY }}:$IMAGE_TAG
docker push ${{ steps.login-ecr.outputs.registry }}/${{ env.ECR_REPOSITORY }}:latest
- name: Deploy to Lightsail Container Service
run: |
aws lightsail create-container-service-deployment \
--service-name cf-analysis-service \
--containers '{"cf-analysis-container": {"image": "729763663166.dkr.ecr.us-east-1.amazonaws.com/crowd-fund-analysis:latest"}}'
- name: Check Deployment Status
id: check-status
run: |
until [[ $(aws lightsail get-container-services --service-name cf-analysis-service --query "containerServices[0].state" --output text) == "RUNNING" ]]; do
echo "Waiting for deployment to complete..."
sleep 15
done
echo "Deployment completed successfully."