Skip to content

Update github actions workflow for AWS ECR deployment #19

Update github actions workflow for AWS ECR deployment

Update github actions workflow for AWS ECR deployment #19

Workflow file for this run

name: Build and Push Docker Image to AWS ECR
on:
push:
branches:
- main
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v3
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Log in to AWS ECR
run: |
aws ecr get-login-password --region ${{ secrets.AWS_REGION }} | docker login --username AWS --password-stdin ${{ secrets.ECR_REPOSITORY }}
- 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