forked from RajRonal/ecs_composite_action
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yaml
73 lines (71 loc) · 2.53 KB
/
action.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
name: Deploy to AWS Environment
inputs:
AWS_REGION:
description: 'deployment region'
required: true
default: 'us-east-1'
CONTAINER_NAME:
description: 'container name'
required: true
ECS_SERVICE:
description: 'service name'
required: true
ECS_CLUSTER:
description: 'cluster name'
required: true
AWS_SECRET_ACCESS_KEY:
description: 'secret key'
required: true
AWS_ACCESS_KEY_ID:
description: 'access key'
required: true
AWS_TASK_DEFINITION:
description: 'ecs task name'
required: true
DOCKER_IMAGE:
description: 'Docker Image'
required: true
runs:
using: 'composite'
steps:
- name: configure aws credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ inputs.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ inputs.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ inputs.AWS_REGION }}
- name: login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Build, tag, and push image to Amazon ECR
id: build-image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: ${{ inputs.CONTAINER_NAME }}
IMAGE_TAG: ${{ github.sha }}
run: |
# Build a docker container and
# push it to ECR so that it can
# be deployed to ECS.
docker tag ${{ inputs.DOCKER_IMAGE }} $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG"
shell: bash
- name: download task definition
run: |
aws ecs describe-task-definition --task-definition ${{ inputs.AWS_TASK_DEFINITION }} --query taskDefinition > task-definition.json
shell: bash
- 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: ${{ inputs.CONTAINER_NAME }}
image: ${{ steps.build-image.outputs.image }}
- 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: ${{ inputs.ECS_SERVICE }}
cluster: ${{ inputs.ECS_CLUSTER }}
wait-for-service-stability: true