Push the Images to the ECR Repository #4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Push the Images to the ECR Repository | |
run-name: Push the Images to the ECR Repository | |
on: | |
workflow_dispatch: | |
env: | |
AWS_ACCESS_KEY: ${{ secrets.AWS_ACCESS_KEY }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }} | |
$ECR_REGISTRY: ${{ secrets.ECR_REGISTRY }} | |
$ECR_REPOSITORY_FRONTEND: ${{ secrets.ECR_REPOSITORY_FRONTEND }} | |
$ECR_REPOSITORY_BACKEND: ${{ secrets.ECR_REPOSITORY_BACKEND }} | |
jobs: | |
ecr: | |
name: Build and Push images | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout the Code | |
uses: actions/checkout@v4 | |
- name: Configure AWS Credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: ${{ secrets.AWS_DEFAULT_REGION }} | |
- name: Login to Amazon ECR | |
uses: aws-actions/amazon-ecr-login@v2 | |
- name: Build and Push the frontend image | |
run: | | |
docker build ./frontend/ -t $ECR_REGISTRY/$ECR_REPOSITORY_FRONTEND:latest | |
docker push $ECR_REGISTRY }}/$ECR_REPOSITORY_FRONTEND:latest | |
- name: Build and Push the backend image | |
run: | | |
docker build ./backend/ -t $ECR_REGISTRY/$ECR_REPOSITORY_BACKEND:latest | |
docker push $ECR_REGISTRY/$ECR_REPOSITORY_BACKEND:latest |