Skip to content

Commit 2ec4b8d

Browse files
authored
Merge pull request #23 from gnanarepo/master
develop-gha: aviso-core-dev and aviso-core-prod deployment pipeline
2 parents 56a09f2 + 55acef0 commit 2ec4b8d

File tree

4 files changed

+162
-32
lines changed

4 files changed

+162
-32
lines changed

.github/workflows/prod.yaml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Deploy to ECS Fargate (Prod)
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
workflow_dispatch:
8+
9+
concurrency:
10+
group: Deploy to ECS Fargate (Prod)
11+
cancel-in-progress: true
12+
13+
jobs:
14+
deploy:
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
# 1. Checkout Code
19+
- name: Checkout repository
20+
uses: actions/checkout@v4
21+
22+
# 2. Configure AWS Credentials
23+
- name: Configure AWS credentials
24+
uses: aws-actions/configure-aws-credentials@v4
25+
with:
26+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
27+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
28+
aws-region: us-east-1
29+
30+
# 3. Login to Amazon ECR
31+
- name: Login to Amazon ECR
32+
id: login-ecr
33+
uses: aws-actions/amazon-ecr-login@v2
34+
35+
# 4. Build & Push Docker Image
36+
- name: Build, Tag, and Push image to ECR
37+
env:
38+
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
39+
ECR_REPOSITORY: aviso-core-prod
40+
IMAGE_TAG: ${{ github.sha }}
41+
run: |
42+
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
43+
docker tag $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG $ECR_REGISTRY/$ECR_REPOSITORY:latest
44+
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
45+
docker push $ECR_REGISTRY/$ECR_REPOSITORY:latest
46+
47+
# 5. Render New ECS Task Definition
48+
- name: Fill in the new image ID in the ECS task definition
49+
id: task-def
50+
uses: aws-actions/amazon-ecs-render-task-definition@v1
51+
with:
52+
task-definition: task-definitions/prod/aviso-core-prod-td.json
53+
container-name: aviso-core
54+
image: ${{ steps.login-ecr.outputs.registry }}/aviso-core-prod:${{ github.sha }}
55+
56+
# 6. Deploy ECS Service
57+
- name: Deploy Amazon ECS task definition
58+
uses: aws-actions/amazon-ecs-deploy-task-definition@v2
59+
with:
60+
task-definition: ${{ steps.task-def.outputs.task-definition }}
61+
service: aviso-core-prod-service
62+
cluster: Prod-Aviso
63+
force-new-deployment: true
64+
wait-for-service-stability: true

.github/workflows/qa.yaml

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ name: Deploy to ECS Fargate (QA)
33
on:
44
push:
55
branches:
6-
- master
6+
- develop
7+
workflow_dispatch:
78

89
concurrency:
910
group: Deploy to ECS Fargate (QA)
@@ -35,7 +36,7 @@ jobs:
3536
- name: Build, Tag, and Push image to ECR
3637
env:
3738
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
38-
ECR_REPOSITORY: aviso-core-qa
39+
ECR_REPOSITORY: aviso-core-dev
3940
IMAGE_TAG: ${{ github.sha }}
4041
run: |
4142
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
@@ -44,20 +45,20 @@ jobs:
4445
docker push $ECR_REGISTRY/$ECR_REPOSITORY:latest
4546
4647
# 5. Render New ECS Task Definition
47-
# - name: Fill in the new image ID in the ECS task definition
48-
# id: task-def
49-
# uses: aws-actions/amazon-ecs-render-task-definition@v1
50-
# with:
51-
# task-definition: task-definitions/qa/aviso-core-qa-td.json
52-
# container-name: aviso-core
53-
# image: ${{ steps.login-ecr.outputs.registry }}/aviso-core-qa:${{ github.sha }}
54-
#
55-
# # 6. Deploy ECS Service
56-
# - name: Deploy Amazon ECS task definition
57-
# uses: aws-actions/amazon-ecs-deploy-task-definition@v2
58-
# with:
59-
# task-definition: ${{ steps.task-def.outputs.task-definition }}
60-
# service: aviso-core-qa
61-
# cluster: Dev-Aviso
62-
# force-new-deployment: true
63-
# wait-for-service-stability: true
48+
- name: Fill in the new image ID in the ECS task definition
49+
id: task-def
50+
uses: aws-actions/amazon-ecs-render-task-definition@v1
51+
with:
52+
task-definition: task-definitions/qa/aviso-core-qa-td.json
53+
container-name: aviso-core
54+
image: ${{ steps.login-ecr.outputs.registry }}/aviso-core-dev:${{ github.sha }}
55+
56+
# 6. Deploy ECS Service
57+
- name: Deploy Amazon ECS task definition
58+
uses: aws-actions/amazon-ecs-deploy-task-definition@v2
59+
with:
60+
task-definition: ${{ steps.task-def.outputs.task-definition }}
61+
service: aviso-core-dev-service
62+
cluster: Dev-Aviso
63+
force-new-deployment: true
64+
wait-for-service-stability: true
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
{
2+
"family": "aviso-core-prod-service-td",
3+
"containerDefinitions": [
4+
{
5+
"name": "aviso-core",
6+
"image": "270591008196.dkr.ecr.us-east-1.amazonaws.com/aviso-core-prod:latest",
7+
"cpu": 0,
8+
"portMappings": [
9+
{
10+
"containerPort": 8000,
11+
"hostPort": 8000,
12+
"protocol": "tcp"
13+
}
14+
],
15+
"essential": true,
16+
"environment": [],
17+
"environmentFiles": [
18+
{
19+
"value": "arn:aws:s3:::prod-aviso-fargate-service-env/aviso-core-prod-env/.env",
20+
"type": "s3"
21+
}
22+
],
23+
"mountPoints": [],
24+
"volumesFrom": [],
25+
"logConfiguration": {
26+
"logDriver": "awslogs",
27+
"options": {
28+
"awslogs-group": "/ecs/aviso-core-prod",
29+
"awslogs-create-group": "true",
30+
"awslogs-region": "us-east-1",
31+
"awslogs-stream-prefix": "ecs"
32+
}
33+
},
34+
"systemControls": []
35+
}
36+
],
37+
"taskRoleArn": "arn:aws:iam::270591008196:role/ecsTaskExecutionRole",
38+
"executionRoleArn": "arn:aws:iam::270591008196:role/ecsTaskExecutionRole",
39+
"networkMode": "awsvpc",
40+
"volumes": [],
41+
"placementConstraints": [],
42+
"requiresCompatibilities": [
43+
"FARGATE"
44+
],
45+
"cpu": "1024",
46+
"memory": "2048",
47+
"runtimePlatform": {
48+
"cpuArchitecture": "X86_64",
49+
"operatingSystemFamily": "LINUX"
50+
},
51+
"tags": [
52+
{
53+
"key": "DeployedBy",
54+
"value": "Backstage"
55+
},
56+
{
57+
"key": "Environment",
58+
"value": "prod"
59+
}
60+
]
61+
}

task-definitions/qa/aviso-core-qa-td.json

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,22 @@
11
{
2-
"family": "aviso-core-qa-td",
2+
"family": "aviso-core-dev-service-td",
33
"containerDefinitions": [
44
{
55
"name": "aviso-core",
6-
"image": "369521641981.dkr.ecr.us-east-1.amazonaws.com/aviso-core-qa:latest",
6+
"image": "369521641981.dkr.ecr.us-east-1.amazonaws.com/aviso-core-dev:latest",
77
"cpu": 0,
88
"portMappings": [
99
{
1010
"containerPort": 8000,
1111
"hostPort": 8000,
12-
"protocol": "tcp",
13-
"appProtocol": "http"
12+
"protocol": "tcp"
1413
}
1514
],
1615
"essential": true,
17-
"command": [
18-
"gunicorn",
19-
"aviso_core.wsgi:application",
20-
"--bind",
21-
"0.0.0.0:8000"
22-
],
2316
"environment": [],
2417
"environmentFiles": [
2518
{
26-
"value": "arn:aws:s3:::dev-aviso-fargate-service-env/aviso-core-qa-env/.env",
19+
"value": "arn:aws:s3:::dev-aviso-fargate-service-env/aviso-core-dev-env/.env",
2720
"type": "s3"
2821
}
2922
],
@@ -32,7 +25,8 @@
3225
"logConfiguration": {
3326
"logDriver": "awslogs",
3427
"options": {
35-
"awslogs-group": "/ecs/aviso-core-qa",
28+
"awslogs-group": "/ecs/aviso-core-dev",
29+
"awslogs-create-group": "true",
3630
"awslogs-region": "us-east-1",
3731
"awslogs-stream-prefix": "ecs"
3832
}
@@ -53,5 +47,15 @@
5347
"runtimePlatform": {
5448
"cpuArchitecture": "X86_64",
5549
"operatingSystemFamily": "LINUX"
56-
}
50+
},
51+
"tags": [
52+
{
53+
"key": "DeployedBy",
54+
"value": "Backstage"
55+
},
56+
{
57+
"key": "Environment",
58+
"value": "dev"
59+
}
60+
]
5761
}

0 commit comments

Comments
 (0)