Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions .github/workflows/prod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Deploy to ECS Fargate (Prod)

on:
push:
branches:
- master
workflow_dispatch:

concurrency:
group: Deploy to ECS Fargate (Prod)
cancel-in-progress: true

jobs:
deploy:
runs-on: ubuntu-latest

steps:
# 1. Checkout Code
- name: Checkout repository
uses: actions/checkout@v4

# 2. Configure AWS Credentials
- 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: us-east-1

# 3. Login to Amazon ECR
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2

# 4. Build & Push Docker Image
- name: Build, Tag, and Push image to ECR
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: aviso-core-prod
IMAGE_TAG: ${{ github.sha }}
run: |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker tag $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG $ECR_REGISTRY/$ECR_REPOSITORY:latest
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
docker push $ECR_REGISTRY/$ECR_REPOSITORY:latest

# 5. Render New ECS Task Definition
- name: Fill in the new image ID in the ECS task definition
id: task-def
uses: aws-actions/amazon-ecs-render-task-definition@v1
with:
task-definition: task-definitions/prod/aviso-core-prod-td.json
container-name: aviso-core
image: ${{ steps.login-ecr.outputs.registry }}/aviso-core-prod:${{ github.sha }}

# 6. Deploy ECS Service
- 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: aviso-core-prod-service
cluster: Prod-Aviso
force-new-deployment: true
wait-for-service-stability: true
39 changes: 20 additions & 19 deletions .github/workflows/qa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ name: Deploy to ECS Fargate (QA)
on:
push:
branches:
- master
- develop
workflow_dispatch:

concurrency:
group: Deploy to ECS Fargate (QA)
Expand Down Expand Up @@ -35,7 +36,7 @@ jobs:
- name: Build, Tag, and Push image to ECR
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: aviso-core-qa
ECR_REPOSITORY: aviso-core-dev
IMAGE_TAG: ${{ github.sha }}
run: |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
Expand All @@ -44,20 +45,20 @@ jobs:
docker push $ECR_REGISTRY/$ECR_REPOSITORY:latest

# 5. Render New ECS Task Definition
# - name: Fill in the new image ID in the ECS task definition
# id: task-def
# uses: aws-actions/amazon-ecs-render-task-definition@v1
# with:
# task-definition: task-definitions/qa/aviso-core-qa-td.json
# container-name: aviso-core
# image: ${{ steps.login-ecr.outputs.registry }}/aviso-core-qa:${{ github.sha }}
#
# # 6. Deploy ECS Service
# - 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: aviso-core-qa
# cluster: Dev-Aviso
# force-new-deployment: true
# wait-for-service-stability: true
- name: Fill in the new image ID in the ECS task definition
id: task-def
uses: aws-actions/amazon-ecs-render-task-definition@v1
with:
task-definition: task-definitions/qa/aviso-core-qa-td.json
container-name: aviso-core
image: ${{ steps.login-ecr.outputs.registry }}/aviso-core-dev:${{ github.sha }}

# 6. Deploy ECS Service
- 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: aviso-core-dev-service
cluster: Dev-Aviso
force-new-deployment: true
wait-for-service-stability: true
61 changes: 61 additions & 0 deletions task-definitions/prod/aviso-core-prod-td.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{
"family": "aviso-core-prod-service-td",
"containerDefinitions": [
{
"name": "aviso-core",
"image": "270591008196.dkr.ecr.us-east-1.amazonaws.com/aviso-core-prod:latest",
"cpu": 0,
"portMappings": [
{
"containerPort": 8000,
"hostPort": 8000,
"protocol": "tcp"
}
],
"essential": true,
"environment": [],
"environmentFiles": [
{
"value": "arn:aws:s3:::prod-aviso-fargate-service-env/aviso-core-prod-env/.env",
"type": "s3"
}
],
"mountPoints": [],
"volumesFrom": [],
"logConfiguration": {
"logDriver": "awslogs",
"options": {
"awslogs-group": "/ecs/aviso-core-prod",
"awslogs-create-group": "true",
"awslogs-region": "us-east-1",
"awslogs-stream-prefix": "ecs"
}
},
"systemControls": []
}
],
"taskRoleArn": "arn:aws:iam::270591008196:role/ecsTaskExecutionRole",
"executionRoleArn": "arn:aws:iam::270591008196:role/ecsTaskExecutionRole",
"networkMode": "awsvpc",
"volumes": [],
"placementConstraints": [],
"requiresCompatibilities": [
"FARGATE"
],
"cpu": "1024",
"memory": "2048",
"runtimePlatform": {
"cpuArchitecture": "X86_64",
"operatingSystemFamily": "LINUX"
},
"tags": [
{
"key": "DeployedBy",
"value": "Backstage"
},
{
"key": "Environment",
"value": "prod"
}
]
}
30 changes: 17 additions & 13 deletions task-definitions/qa/aviso-core-qa-td.json
Original file line number Diff line number Diff line change
@@ -1,29 +1,22 @@
{
"family": "aviso-core-qa-td",
"family": "aviso-core-dev-service-td",
"containerDefinitions": [
{
"name": "aviso-core",
"image": "369521641981.dkr.ecr.us-east-1.amazonaws.com/aviso-core-qa:latest",
"image": "369521641981.dkr.ecr.us-east-1.amazonaws.com/aviso-core-dev:latest",
"cpu": 0,
"portMappings": [
{
"containerPort": 8000,
"hostPort": 8000,
"protocol": "tcp",
"appProtocol": "http"
"protocol": "tcp"
}
],
"essential": true,
"command": [
"gunicorn",
"aviso_core.wsgi:application",
"--bind",
"0.0.0.0:8000"
],
"environment": [],
"environmentFiles": [
{
"value": "arn:aws:s3:::dev-aviso-fargate-service-env/aviso-core-qa-env/.env",
"value": "arn:aws:s3:::dev-aviso-fargate-service-env/aviso-core-dev-env/.env",
"type": "s3"
}
],
Expand All @@ -32,7 +25,8 @@
"logConfiguration": {
"logDriver": "awslogs",
"options": {
"awslogs-group": "/ecs/aviso-core-qa",
"awslogs-group": "/ecs/aviso-core-dev",
"awslogs-create-group": "true",
"awslogs-region": "us-east-1",
"awslogs-stream-prefix": "ecs"
}
Expand All @@ -53,5 +47,15 @@
"runtimePlatform": {
"cpuArchitecture": "X86_64",
"operatingSystemFamily": "LINUX"
}
},
"tags": [
{
"key": "DeployedBy",
"value": "Backstage"
},
{
"key": "Environment",
"value": "dev"
}
]
}
Loading