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
  • Loading branch information
floriantz committed Oct 18, 2024
1 parent ce95bbe commit a6db883
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: |

Check failure on line 72 in .github/workflows/docker-tag-v1.yml

View workflow job for this annotation

GitHub Actions / lint

shellcheck reported issue in this script: SC1009:info:6:3: The mentioned syntax error was in this simple command

Check failure on line 72 in .github/workflows/docker-tag-v1.yml

View workflow job for this annotation

GitHub Actions / lint

shellcheck reported issue in this script: SC1073:error:6:99: Couldn't parse this double quoted string. Fix to allow more checks

Check failure on line 72 in .github/workflows/docker-tag-v1.yml

View workflow job for this annotation

GitHub Actions / lint

shellcheck reported issue in this script: SC1072:error:9:1: Expected end of double quoted string. Fix any mentioned problems and try again
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 a6db883

Please sign in to comment.