This repository was archived by the owner on Aug 22, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yml
More file actions
75 lines (71 loc) · 2.52 KB
/
action.yml
File metadata and controls
75 lines (71 loc) · 2.52 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
name: 'ECS Deploy Action'
description: Github action to deploy to ECS
inputs:
aws-access-key-id:
description: AWS Access Key ID
required: true
aws-secret-access-key:
description: AWS Access Key
required: true
aws-role-to-assume:
description: AWS Role to assume
required: true
aws-region:
description: AWS Region
required: false
default: eu-central-1
ecr-registry:
description: ECS Registry to deploy to
required: true
ecr-repository:
description: ECS Repository to deploy to
required: true
ecs-cluster:
description: ECS Cluster to deploy to
required: true
container-name:
description: Container name to deploy
required: true
task-definition:
description: Name of the task definition
required: false
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 }}
role-to-assume: ${{ inputs.aws-role-to-assume }}
role-skip-session-tagging: true
role-duration-seconds: 3600
- name: Set image tag
run: |
COMMIT_HASH=${{ github.event.pull_request.head.sha }}
echo "IMAGE_TAG=${COMMIT_HASH:0:7}" >> $GITHUB_ENV
shell: bash
- name: Download task definition
run: |
aws ecs describe-task-definition --task-definition ${{ inputs.task-definition || inputs.ecr-repository }} --query taskDefinition > task-definition.json
shell: bash
- name: Patch the awslogs-stream-prefix with IMAGE_TAG
run: |
jq ".containerDefinitions[].logConfiguration.options[\"awslogs-stream-prefix\"] = \"${{ env.IMAGE_TAG }}\"" task-definition.json > task-definition2.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-definition2.json
container-name: ${{ inputs.container-name }}
image: ${{ inputs.ecr-registry }}/${{ inputs.ecr-repository }}:${{ env.IMAGE_TAG }}
- name: Run Task on Amazon ECS
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
with:
task-definition: ${{ steps.task-def.outputs.task-definition }}
cluster: ${{ inputs.ecs-cluster }}
count: 1
started-by: github-actions-${{ github.actor }}
wait-for-finish: true