diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..2a6558a --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,67 @@ +name: Deploy Backend to ECS + +on: + push: + branches: + - main + workflow_dispatch: # 手動実行用 + +permissions: + contents: read + id-token: write + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v6 + + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v5.1.1 + with: + role-to-assume: ${{ secrets.AWS_ROLE_ARN }} + aws-region: ${{ secrets.AWS_REGION }} + + - name: Login to Amazon ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@v2 + + # DockerイメージのビルドとPush (SHAとlatestの両方を付与) + - name: Build, tag, and push image to Amazon ECR + id: build-image + env: + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} + IMAGE_TAG: ${{ github.sha }} + ECR_REPOSITORY: ${{ secrets.ECR_REPOSITORY_NAME }} + run: | + docker build --platform linux/amd64 \ + -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG \ + -t $ECR_REGISTRY/$ECR_REPOSITORY:latest . + + docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG + docker push $ECR_REGISTRY/$ECR_REPOSITORY:latest + + echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT + + - name: Download task definition + run: | + aws ecs describe-task-definition --task-definition ${{ secrets.ECS_TASK_DEFINITION_NAME }} \ + --query taskDefinition > task-definition.json + + - name: Fill in the new image ID in the Amazon ECS task definition + id: task-def + uses: aws-actions/amazon-ecs-render-task-definition@v1 + with: + task-definition: task-definition.json + container-name: ${{ secrets.ECS_CONTAINER_NAME }} + image: ${{ steps.build-image.outputs.image }} + + # 新しいタスク定義をデプロイし、サービスの安定化を待つ + - name: Deploy Amazon ECS task definition + uses: aws-actions/amazon-ecs-deploy-task-definition@v2 + with: + task-definition: ${{ steps.task-def.outputs.task-definition }} + service: ${{ secrets.ECS_SERVICE_NAME }} + cluster: ${{ secrets.ECS_CLUSTER_NAME }} + wait-for-service-stability: true \ No newline at end of file diff --git a/docs/database.md b/docs/database.md index dcd321e..6384005 100644 --- a/docs/database.md +++ b/docs/database.md @@ -126,6 +126,10 @@ erDiagram string llm_importance_level "重要度" + string llm_priority "優先度" + + string llm_fix_difficulty "修正難易度" + boolean llm_is_abusive "危険かどうか" boolean is_analyzed "分析したかどうか"