Skip to content

Commit

Permalink
chore(docker-tag): do not fail if tag already exists to make action m…
Browse files Browse the repository at this point in the history
…ore idempotent (#172)

* chore(docker-tag): do not fail if tag already exists to make action more idempotent

* fix(bash): fixscript
  • Loading branch information
floriantz authored Oct 21, 2024
1 parent ce95bbe commit 4a8c420
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/docker-tag-v1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,10 @@ jobs:
- name: Tag image
run: |
MANIFEST=$(aws ecr batch-get-image --repository-name ${{ inputs.image_name }} --image-ids imageTag=${{ inputs.image_tag_from }} --output text --query 'images[].imageManifest')
aws ecr put-image --repository-name ${{ inputs.image_name }} --image-tag ${{ inputs.image_tag_to}} --image-manifest "$MANIFEST"
IMAGE_EXISTS=$(aws ecr describe-images --repository-name ${{ inputs.image_name }} --image-ids imageTag=${{ inputs.image_tag_to}})
if [[ -z "$IMAGE_EXISTS" ]]; then
MANIFEST=$(aws ecr batch-get-image --repository-name ${{ inputs.image_name }} --image-ids imageTag=${{ inputs.image_tag_from }} --output text --query 'images[].imageManifest')
aws ecr put-image --repository-name ${{ inputs.image_name }} --image-tag ${{ inputs.image_tag_to }} --image-manifest "$MANIFEST"
else
echo "image ${{ inputs.image_name }} tag ${{ inputs.image_tag_to }} already exists. Skipping..."
fi

0 comments on commit 4a8c420

Please sign in to comment.