File tree Expand file tree Collapse file tree 3 files changed +12
-4
lines changed Expand file tree Collapse file tree 3 files changed +12
-4
lines changed Original file line number Diff line number Diff line change 50
50
skip_when_tags_exist : <<parameters.skip_when_tags_exist>>
51
51
source_tag : <<parameters.source_tag>>
52
52
target_tag : <<parameters.target_tag>>
53
+ profile_name : <<parameters.profile_name>>
53
54
build-test-then-push-with-buildx :
54
55
machine :
55
56
image : ubuntu-2204:2022.07.1
Original file line number Diff line number Diff line change @@ -21,6 +21,11 @@ parameters:
21
21
description : Whether to skip tagging an image if any specified tags already exist
22
22
type : boolean
23
23
24
+ profile_name :
25
+ default : " default"
26
+ description : AWS profile to use
27
+ type : string
28
+
24
29
steps :
25
30
- run :
26
31
name : <<parameters.target_tag>> tag to <<parameters.repo>>:<<parameters.source_tag>>
29
34
AWS_ECR_STR_SOURCE_TAG : <<parameters.source_tag>>
30
35
AWS_ECR_STR_TARGET_TAG : <<parameters.target_tag>>
31
36
AWS_ECR_BOOL_SKIP_WHEN_TAGS_EXIST : <<parameters.skip_when_tags_exist>>
37
+ AWS_ECR_STR_AWS_PROFILE : <<parameters.profile_name>>
32
38
command : <<include(scripts/tag_image.sh)>>
Original file line number Diff line number Diff line change 2
2
AWS_ECR_EVAL_REPO=" $( eval echo " ${AWS_ECR_STR_REPO} " ) "
3
3
AWS_ECR_EVAL_SOURCE_TAG=" $( eval echo " ${AWS_ECR_STR_SOURCE_TAG} " ) "
4
4
AWS_ECR_EVAL_TARGET_TAG=" $( eval echo " ${AWS_ECR_STR_TARGET_TAG} " ) "
5
+ AWS_ECR_EVAL_AWS_PROFILE=" $( eval echo " ${AWS_ECR_STR_AWS_PROFILE} " ) "
5
6
6
7
# pull the image manifest from ECR
7
8
set -x
8
- MANIFEST=" $( aws ecr batch-get-image --repository-name " ${AWS_ECR_EVAL_REPO} " --image-ids imageTag=" ${AWS_ECR_EVAL_SOURCE_TAG} " --query ' images[].imageManifest' --output text) "
9
- EXISTING_TAGS=" $( aws ecr list-images --repository-name " ${AWS_ECR_EVAL_REPO} " --filter " tagStatus=TAGGED" ) "
9
+ MANIFEST=" $( aws ecr batch-get-image --repository-name " ${AWS_ECR_EVAL_REPO} " --image-ids imageTag=" ${AWS_ECR_EVAL_SOURCE_TAG} " --query ' images[].imageManifest' --output text --profile " ${AWS_ECR_EVAL_AWS_PROFILE} " ) "
10
+ EXISTING_TAGS=" $( aws ecr list-images --repository-name " ${AWS_ECR_EVAL_REPO} " --filter " tagStatus=TAGGED" --profile " ${AWS_ECR_EVAL_AWS_PROFILE} " ) "
10
11
IFS=" ," read -ra ECR_TAGS <<< " ${AWS_ECR_EVAL_TARGET_TAG}"
11
12
12
13
for tag in " ${ECR_TAGS[@]} " ; do
13
14
# if skip_when_tags_exist is true
14
15
if [ " ${AWS_ECR_BOOL_SKIP_WHEN_TAGS_EXIST} " -eq 1 ]; then
15
16
# tag image if tag does not exist
16
17
if ! echo " ${EXISTING_TAGS} " | grep " ${tag} " ; then
17
- aws ecr put-image --repository-name " ${AWS_ECR_EVAL_REPO} " --image-tag " ${tag} " --image-manifest " ${MANIFEST} "
18
+ aws ecr put-image --repository-name " ${AWS_ECR_EVAL_REPO} " --image-tag " ${tag} " --image-manifest " ${MANIFEST} " --profile " ${AWS_ECR_EVAL_AWS_PROFILE} "
18
19
else
19
20
echo " Tag \" ${tag} \" already exists and will be skipped."
20
21
fi
21
22
# tag image when skip_when_tags_exist is false
22
23
else
23
- aws ecr put-image --repository-name " ${AWS_ECR_EVAL_REPO} " --image-tag " ${tag} " --image-manifest " ${MANIFEST} "
24
+ aws ecr put-image --repository-name " ${AWS_ECR_EVAL_REPO} " --image-tag " ${tag} " --image-manifest " ${MANIFEST} " --profile " ${AWS_ECR_EVAL_AWS_PROFILE} "
24
25
fi
25
26
done
26
27
set +x
You can’t perform that action at this time.
0 commit comments