Skip to content

Commit 63571d1

Browse files
committed
Set lifecycle rules
1 parent c71bc81 commit 63571d1

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

.circleci/config.yml

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ orbs:
77
# https://circleci.com/orbs/registry/orb/circleci/aws-ecr
88
# required environment variables:
99
# https://circleci.com/docs/2.0/ecs-ecr/#configure-circleci-environment-variables
10-
aws-ecr: circleci/aws-ecr@6.15.3
10+
aws-ecr: circleci/aws-ecr@8.1.2
1111

1212
workflows:
1313
version: 2
@@ -32,6 +32,36 @@ workflows:
3232
tag: "latest,$CIRCLE_BRANCH,$CIRCLE_SHA1"
3333
# create the AWS ECR repo if it does not exist already.
3434
create-repo: true
35+
lifecycle-policy-path: >
36+
{
37+
"rules": [
38+
{
39+
"rulePriority": 1,
40+
"description": "Keep latest master image",
41+
"selection": {
42+
"tagStatus": "tagged",
43+
"tagPrefixList": ["master", "main"],
44+
"countType": "imageCountMoreThan",
45+
"countNumber": 5
46+
},
47+
"action": {
48+
"type": "expire"
49+
}
50+
},
51+
{
52+
"rulePriority": 2,
53+
"description": "Expire all images older than 90 days.",
54+
"selection": {
55+
"countType": "sinceImagePushed",
56+
"countNumber": 90,
57+
"countUnit": "days"
58+
},
59+
"action": {
60+
"type": "expire"
61+
}
62+
}
63+
]
64+
}
3565
# provide the aws-ecr context (environment variables) to push docker_image into ecr.
3666
# https://circleci.com/docs/2.0/ecs-ecr/#configure-circleci-environment-variables
3767
context: aws-ecr

0 commit comments

Comments
 (0)