From 63571d1eb04af4beb57b49ee78ca0405d407ea6f Mon Sep 17 00:00:00 2001 From: Ignacio Nin Date: Thu, 26 May 2022 15:25:26 -0300 Subject: [PATCH] Set lifecycle rules --- .circleci/config.yml | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 5037682..ae78691 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -7,7 +7,7 @@ orbs: # https://circleci.com/orbs/registry/orb/circleci/aws-ecr # required environment variables: # https://circleci.com/docs/2.0/ecs-ecr/#configure-circleci-environment-variables - aws-ecr: circleci/aws-ecr@6.15.3 + aws-ecr: circleci/aws-ecr@8.1.2 workflows: version: 2 @@ -32,6 +32,36 @@ workflows: tag: "latest,$CIRCLE_BRANCH,$CIRCLE_SHA1" # create the AWS ECR repo if it does not exist already. create-repo: true + lifecycle-policy-path: > + { + "rules": [ + { + "rulePriority": 1, + "description": "Keep latest master image", + "selection": { + "tagStatus": "tagged", + "tagPrefixList": ["master", "main"], + "countType": "imageCountMoreThan", + "countNumber": 5 + }, + "action": { + "type": "expire" + } + }, + { + "rulePriority": 2, + "description": "Expire all images older than 90 days.", + "selection": { + "countType": "sinceImagePushed", + "countNumber": 90, + "countUnit": "days" + }, + "action": { + "type": "expire" + } + } + ] + } # provide the aws-ecr context (environment variables) to push docker_image into ecr. # https://circleci.com/docs/2.0/ecs-ecr/#configure-circleci-environment-variables context: aws-ecr