Skip to content

Commit

Permalink
Update github actions workflow for AWS ECR deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
Aahil13 committed Aug 19, 2024
1 parent 048b2d3 commit 3d54799
Showing 1 changed file with 16 additions and 19 deletions.
35 changes: 16 additions & 19 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,20 @@ jobs:
steps:
- name: Check out the repo
uses: actions/checkout@v3

- name: Log in to AWS ECR
id: ecr-login
run: |
aws ecr get-login-password --region ${{ secrets.AWS_REGION }} | docker login --username AWS --password-stdin ${{ secrets.ECR_REPOSITORY }}
- name: Log in to Docker Hub
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: aahil13/myapp

- name: Build and push Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Build Docker image
run: |
docker build -t ${{ secrets.ECR_REPOSITORY }}:latest .
- name: Tag Docker image
run: |
docker tag ${{ secrets.ECR_REPOSITORY }}:latest ${{ secrets.ECR_REPOSITORY }}:latest
- name: Push Docker image to AWS ECR
run: |
docker push ${{ secrets.ECR_REPOSITORY }}:latest

0 comments on commit 3d54799

Please sign in to comment.