Skip to content

Commit

Permalink
Deploy job inlcuded in workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
devops4sure committed Nov 10, 2023
1 parent 2d92d44 commit 3e339eb
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 4 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ name: Hprofile Actions
on: workflow_dispatch
env:
AWS_REGION: us-east-2
ECR_REPOSITORY: actapp
ECS_SERVICE: vproapp-act-svc
ECS_CLUSTER: vproapp-act
ECS_TASK_DEFINITION: aws-files/taskdeffile.json
CONTAINER_NAME: vproapp

jobs:
Testing:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -75,4 +81,36 @@ jobs:
dockerfile: ./Dockerfile
context: ./

Deploy:
needs: BUILD_AND_PUBLISH
runs-on: ubuntu-latest
steps:
- name: Code checkout
uses: actions/checkout@v4

- 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: ${{ env.AWS_REGION }}

- 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: ${{ env.ECS_TASK_DEFINITION }}
container-name: ${{ env.CONTAINER_NAME }}
image: ${{ secrets.REGISTRY }}/${{ env.ECR_REPOSITORY }}:${{ github.run_number }}

- name: Deploy Amazon ECS task definition
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
with:
task-definition: ${{ steps.task-def.outputs.task-definition }}
service: ${{ env.ECS_SERVICE }}
cluster: ${{ env.ECS_CLUSTER }}
wait-for-service-stability: true




45 changes: 41 additions & 4 deletions aws-files/taskdeffile.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"family": "vproappstagetask",
"taskDefinitionArn": "arn:aws:ecs:us-east-2:716657688884:task-definition/vproapp-act-tdef:1",
"containerDefinitions": [
{
"name": "vproapp",
"image": "716657688884.dkr.ecr.us-east-2.amazonaws.com/actapp:latest",
"image": "716657688884.dkr.ecr.us-east-2.amazonaws.com/actapp",
"cpu": 0,
"portMappings": [
{
Expand All @@ -24,16 +24,51 @@
"logDriver": "awslogs",
"options": {
"awslogs-create-group": "true",
"awslogs-group": "/ecs/vproappstagetask",
"awslogs-group": "/ecs/vproapp-act-tdef",
"awslogs-region": "us-east-2",
"awslogs-stream-prefix": "ecs"
},
"secretOptions": []
}
}
],
"family": "vproapp-act-tdef",
"executionRoleArn": "arn:aws:iam::716657688884:role/ecsTaskExecutionRole",
"networkMode": "awsvpc",
"revision": 1,
"volumes": [],
"status": "ACTIVE",
"requiresAttributes": [
{
"name": "com.amazonaws.ecs.capability.logging-driver.awslogs"
},
{
"name": "ecs.capability.execution-role-awslogs"
},
{
"name": "com.amazonaws.ecs.capability.ecr-auth"
},
{
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.19"
},
{
"name": "ecs.capability.execution-role-ecr-pull"
},
{
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.18"
},
{
"name": "ecs.capability.task-eni"
},
{
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.29"
}
],
"placementConstraints": [],
"compatibilities": [
"EC2",
"FARGATE"
],
"requiresCompatibilities": [
"FARGATE"
],
Expand All @@ -43,10 +78,12 @@
"cpuArchitecture": "X86_64",
"operatingSystemFamily": "LINUX"
},
"registeredAt": "2023-11-10T18:02:04.388Z",
"registeredBy": "arn:aws:iam::716657688884:root",
"tags": [
{
"key": "Name",
"value": "vprofileappstagtaskdef"
"value": "vproapp-act-tdef"
}
]
}

0 comments on commit 3e339eb

Please sign in to comment.