Skip to content

Commit 76f99c7

Browse files
committed
fix: ecr
1 parent c105564 commit 76f99c7

1 file changed

Lines changed: 27 additions & 29 deletions

File tree

.github/workflows/push-to-ecr.yml

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -99,38 +99,36 @@ jobs:
9999
role-to-assume: ${{ secrets.role }}
100100
role-session-name: GitHub_Action_LambdaPerf_Session
101101
aws-region: ${{ inputs.environment == 'DEV' && secrets.devRegion || inputs.environment == 'PROD' && secrets.prodRegion }}
102-
- name: clean untagged images
103-
env:
104-
AWS_REGION: ${{ inputs.environment == 'DEV' && secrets.devRegion || inputs.environment == 'PROD' && secrets.prodRegion }}
105-
run: |
106-
echo "Fetching untagged images..."
107-
108-
IMAGES=$(aws ecr list-images \
109-
--region "${AWS_REGION}" \
110-
--repository-name lambda-perf \
111-
--filter "tagStatus=UNTAGGED" \
112-
--query 'imageIds' \
113-
--output json)
114-
115-
COUNT=$(echo "$IMAGES" | jq length)
102+
- name: clean untagged images
103+
env:
104+
AWS_REGION: ${{ inputs.environment == 'DEV' && secrets.devRegion || inputs.environment == 'PROD' && secrets.prodRegion }}
105+
run: |
106+
echo "Fetching untagged images..."
116107
117-
if [ "$COUNT" -eq 0 ]; then
118-
echo "No untagged images found. Skipping deletion."
119-
exit 0
120-
fi
108+
IMAGES=$(aws ecr list-images \
109+
--region "${AWS_REGION}" \
110+
--repository-name lambda-perf \
111+
--filter "tagStatus=UNTAGGED" \
112+
--query 'imageIds' \
113+
--output json)
121114
122-
echo "Found $COUNT untagged images. Deleting in batches of 100..."
115+
COUNT=$(echo "$IMAGES" | jq length)
123116
124-
# Split into chunks of 100
125-
echo "$IMAGES" | jq -c '.[]' | split -l 100 -d batch_
117+
if [ "$COUNT" -eq 0 ]; then
118+
echo "No untagged images found. Skipping deletion."
119+
exit 0
120+
fi
126121
127-
for batch in batch_*; do
128-
IDS=$(jq -s '.' "$batch")
129-
echo "Deleting batch: $batch"
130-
aws ecr batch-delete-image \
131-
--region "${AWS_REGION}" \
132-
--repository-name lambda-perf \
133-
--image-ids "$IDS"
134-
done
122+
echo "Found $COUNT untagged images. Deleting in batches of 100..."
135123
124+
# Split into chunks of 100
125+
echo "$IMAGES" | jq -c '.[]' | split -l 100 -d batch_
136126
127+
for batch in batch_*; do
128+
IDS=$(jq -s '.' "$batch")
129+
echo "Deleting batch: $batch"
130+
aws ecr batch-delete-image \
131+
--region "${AWS_REGION}" \
132+
--repository-name lambda-perf \
133+
--image-ids "$IDS"
134+
done

0 commit comments

Comments
 (0)