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: Docker Image ECR CI | |
on: | |
push: | |
branches: | |
- '**' | |
env: | |
AWS_REGION: eu-central-1 | |
ECR_REPO_URI: ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.eu-north-1.amazonaws.com/flask-app | |
IMAGE_NAME: flask-app | |
TAG: latest | |
jobs: | |
docker-build-push: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
- uses: actions/checkout@v4 | |
- name: Configure AWS credentials from Test account | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
role-to-assume: ${{ secrets.AWS_IAM_ROLE }} | |
aws-region: ${{ env.AWS_REGION }} | |
- name: Login to Amazon ECR | |
run: | | |
echo ${{ env.AWS_SECRET_ACCESS_KEY }} | docker login --username AWS --password-stdin ${{ env.AWS_ACCOUNT_ID }}.dkr.ecr.${{ env.AWS_REGION }}.amazonaws.com | |
- name: Build and Push Docker Image | |
run: | | |
docker build -t ${{ env.IMAGE_NAME }}:${{ env.TAG }} . | |
docker tag ${{ env.IMAGE_NAME }}:${{ env.TAG }} ${{ env.ECR_REPO_URI }}/${{ env.IMAGE_NAME }}:${{ env.TAG }} | |
docker push ${{ env.ECR_REPO_URI }}/${{ env.IMAGE_NAME }}:${{ env.TAG }} |