Update github actions workflow for AWS ECR deployment #17
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: Publish Docker image | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
jobs: | |
push_to_registry: | |
name: Push Docker image to Docker HUB | |
runs-on: ubuntu-latest | |
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: 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 |