-
Notifications
You must be signed in to change notification settings - Fork 0
97 lines (85 loc) · 2.79 KB
/
ecs_push.yml
File metadata and controls
97 lines (85 loc) · 2.79 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
name: Push to ECS
on:
workflow_call:
inputs:
project-name:
required: true
type: string
ecr-repository:
required: true
type: string
ecs-cluster:
required: true
type: string
ecs-service:
required: true
type: string
container-name:
required: true
type: string
docker-file-path:
required: true
type: string
task-definition:
required: true
type: string
secrets:
AWS_ACCESS_KEY_ID:
required: true
AWS_SECRET_ACCESS_KEY:
required: true
AWS_REGION:
required: true
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Download the gradle Build File
uses: actions/download-artifact@v4
with:
name: ${{inputs.project-name}}-build
path: ./Bootstrap-Module/${{inputs.project-name}}/build/libs
- name: Configure AWS credentials For ECR
uses: aws-actions/configure-aws-credentials@v1
with:
aws-region: ${{ secrets.AWS_REGION }}
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Docker Build And Push
uses: docker/build-push-action@v4
with:
context: .
push: true
file: ${{ inputs.docker-file-path }}
tags: |
${{ inputs.ecr-repository }}:${{ github.sha }}
${{ inputs.ecr-repository }}:latest
platforms: |
linux/amd64
linux/arm64
- name: Download Task Definition Template
run: |
aws ecs describe-task-definition --task-definition ${{ inputs.task-definition }} --query taskDefinition > task-definition.json
- name: Replace the image name in ${{inputs.project-name}} ECS task definition
id: task-definition
uses: aws-actions/amazon-ecs-render-task-definition@v1
with:
task-definition: task-definition.json
container-name: ${{ inputs.container-name }}
image: ${{ inputs.ecr-repository }}:${{ github.sha }}
- name: Deploy New ${{inputs.project-name}} ECS Task Definition
uses: aws-actions/amazon-ecs-deploy-task-definition@v2
with:
task-definition: ${{ steps.task-definition.outputs.task-definition }}
service: ${{ inputs.ecs-service }}
cluster: ${{ inputs.ecs-cluster }}
wait-for-service-stability: true