-
Notifications
You must be signed in to change notification settings - Fork 0
80 lines (73 loc) · 2.35 KB
/
Copy pathecs-deploy.yml
File metadata and controls
80 lines (73 loc) · 2.35 KB
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
74
75
76
77
78
79
80
name: Deploy service to ECS
on:
workflow_call:
inputs:
environment:
required: true
type: string
cluster:
required: true
type: string
image:
required: true
type: string
container-name:
required: true
type: string
service-name:
required: true
type: string
timeout-minutes:
required: false
type: number
default: 5
wait-for-service-stability:
required: false
type: boolean
default: true
permissions:
contents: read
id-token: write
jobs:
deploy:
name: Deploy
runs-on: ubuntu-latest
concurrency:
group: ecs-deploy-${{ inputs.service-name }}-${{ inputs.environment }}-${{ github.head_ref || github.run_id }}
steps:
- name: Set up env
run: |
if [ "${{ inputs.environment }}" = "production" ]; then
echo "AWS_ROLE_ARN=arn:aws:iam::120317779495:role/github" >> $GITHUB_ENV
elif [ "${{ inputs.environment }}" = "staging" ]; then
echo "AWS_ROLE_ARN=arn:aws:iam::680542703984:role/github" >> $GITHUB_ENV
else
echo "unrecognized environment"
exit 1;
fi
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@d979d5b3a71173a29b74b5b88418bfda9437d885 # v6.1.1
with:
role-to-assume: ${{ env.AWS_ROLE_ARN }}
aws-region: us-east-1
- name: Fetch latest task definition
run: >
aws ecs describe-task-definition
--task-definition ${{ inputs.service-name }}
--query taskDefinition
> task-definition.json
- id: task-def
uses: aws-actions/amazon-ecs-render-task-definition@v1
with:
task-definition: task-definition.json
container-name: ${{ inputs.container-name }}
image: ${{ inputs.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: ${{ inputs.service-name }}
cluster: ${{ inputs.cluster }}
wait-for-service-stability: ${{ inputs.wait-for-service-stability }}
force-new-deployment: true
wait-for-minutes: ${{ inputs.timeout-minutes }}