Skip to content

Commit

Permalink
Merge pull request #10 from fullfatthings/respect-other-containers
Browse files Browse the repository at this point in the history
Only substitute images from the same respository
  • Loading branch information
OwlKing authored Oct 3, 2024
2 parents cd6df68 + 8080daf commit 00953bd
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 21 deletions.
17 changes: 12 additions & 5 deletions .github/workflows/update-background-service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ on:
github-actions-role:
required: true
type: string
image:
images:
description: 'A semicolon separated list of images to update'
required: true
type: string
service:
Expand Down Expand Up @@ -48,13 +49,19 @@ jobs:
> task-definition.json
- name: Render task definition
run: >
jq '.containerDefinitions[].image = "${{ steps.ecr-login.outputs.registry }}/${{ inputs.image }}"' task-definition.json
> new-task-definition.json
run: |
IFS=";" read -a IMAGES <<< "${{ inputs.images }}"
for image in "${IMAGES[@]}"
do
FULL_IMAGE="${{ steps.ecr-login.outputs.registry }}/$image"
REPOSITORY=${FULL_IMAGE%:*}
jq ".containerDefinitions[] |= if (.image | startswith(\"$REPOSITORY\")) then (.image = \"$FULL_IMAGE\") else . end" task-definition.json > new-task-definition.json
mv new-task-definition.json task-definition.json
done
- name: Deploy task definition
uses: fullfatthings/amazon-ecs-deploy-task-definition@master
with:
task-definition: new-task-definition.json
task-definition: task-definition.json
service: ${{ inputs.service }}
cluster: ${{ inputs.cluster }}
17 changes: 12 additions & 5 deletions .github/workflows/update-task-definition.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ on:
github-actions-role:
required: true
type: string
image:
images:
description: 'A semicolon separated list of images to update'
required: true
type: string
task-definition-family:
Expand Down Expand Up @@ -45,12 +46,18 @@ jobs:
> task-definition.json
- name: Render task definition
run: >
jq '.containerDefinitions[].image = "${{ steps.ecr-login.outputs.registry }}/${{ inputs.image }}"' task-definition.json
> new-task-definition.json
run: |
IFS=";" read -a IMAGES <<< "${{ inputs.images }}"
for image in "${IMAGES[@]}"
do
FULL_IMAGE="${{ steps.ecr-login.outputs.registry }}/$image"
REPOSITORY=${FULL_IMAGE%:*}
jq ".containerDefinitions[] |= if (.image | startswith(\"$REPOSITORY\")) then (.image = \"$FULL_IMAGE\") else . end" task-definition.json > new-task-definition.json
mv new-task-definition.json task-definition.json
done
- name: Deploy task definition
uses: fullfatthings/amazon-ecs-deploy-task-definition@master
with:
task-definition: new-task-definition.json
task-definition: task-definition.json
cluster: ${{ inputs.cluster }}
17 changes: 12 additions & 5 deletions .github/workflows/update-web-service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ on:
github-actions-role:
required: true
type: string
image:
images:
description: 'A semicolon separated list of images to update'
required: true
type: string
service:
Expand Down Expand Up @@ -48,14 +49,20 @@ jobs:
> task-definition.json
- name: Render task definition
run: >
jq '.containerDefinitions[].image = "${{ steps.ecr-login.outputs.registry }}/${{ inputs.image }}"' task-definition.json
> new-task-definition.json
run: |
IFS=";" read -a IMAGES <<< "${{ inputs.images }}"
for image in "${IMAGES[@]}"
do
FULL_IMAGE="${{ steps.ecr-login.outputs.registry }}/$image"
REPOSITORY=${FULL_IMAGE%:*}
jq ".containerDefinitions[] |= if (.image | startswith(\"$REPOSITORY\")) then (.image = \"$FULL_IMAGE\") else . end" task-definition.json > new-task-definition.json
mv new-task-definition.json task-definition.json
done
- name: Deploy task definition
uses: fullfatthings/amazon-ecs-deploy-task-definition@master
with:
task-definition: new-task-definition.json
task-definition: task-definition.json
service: ${{ inputs.service }}
cluster: ${{ inputs.cluster }}
wait-for-service-stability: true
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ Arguments:
* `aws-region`: The AWS region the cluster resides in.
* `cluster`: The name of the ECS cluster.
* `github-actions-role`: The ARN of the above role.
* `image`: The new ECR image to use. Should not include the *.amazonaws.com/
prefix.
* `images`: A semicolon-separated list of the new ECR images to use. Should not
include the *.amazonaws.com/ prefix.
* `service`: The name of the service to update to use the new task definition.
* `task-definition-family`: Name of the task definition family.

Expand All @@ -106,8 +106,8 @@ Arguments:
* `aws-region`: The AWS region the cluster resides in.
* `cluster`: The name of the ECS cluster.
* `github-actions-role`: The ARN of the above role.
* `image`: The new ECR image to use. Should not include the *.amazonaws.com/
prefix.
* `images`: A semicolon-separated list of the new ECR images to use. Should not
include the *.amazonaws.com/ prefix.
* `task-definition-family`: Name of the task definition family.

## update-web-service.yml
Expand All @@ -122,7 +122,7 @@ Arguments:
* `aws-region`: The AWS region the cluster resides in.
* `cluster`: The name of the ECS cluster.
* `github-actions-role`: The ARN of the above role.
* `image`: The new ECR image to use. Should not include the *.amazonaws.com/
prefix.
* `images`: A semicolon-separated list of the new ECR images to use. Should not
include the *.amazonaws.com/ prefix.
* `service`: The name of the service to update to use the new task definition.
* `task-definition-family`: Name of the task definition family.

0 comments on commit 00953bd

Please sign in to comment.