Skip to content

Commit

Permalink
Added action to build and push to ECR
Browse files Browse the repository at this point in the history
  • Loading branch information
forkimenjeckayang committed Jun 20, 2024
1 parent 81f06ec commit d796229
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/build_push_to_ECR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,16 @@ jobs:
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2

- name: Delete previous images in ECR
run: |
REPO_NAME=${{ secrets.REPO_NAME }}
IMAGES=$(aws ecr list-images --repository-name $REPO_NAME --query 'imageIds[*]' --output json)
aws ecr batch-delete-image --repository-name $REPO_NAME --image-ids "$IMAGES"
- name: Build, tag, and push the image to Amazon ECR
id: build-image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: ${{ secrets.REPO_NAME }}
run: |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:latest .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:latest
docker push $ECR_REGISTRY/$ECR_REPOSITORY:latest

0 comments on commit d796229

Please sign in to comment.