[ECR] build & push backend image #36
Workflow file for this run
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: ECR | Backend - Build Image & Push to ECR | |
on: | |
push: | |
tags: | |
- "backend/v*" | |
jobs: | |
build_and_push: | |
name: "Build Backend Image From Git Tag" | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.ref_name }} | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: ${{ secrets.AWS_DEFAULT_REGION }} | |
- name: Login to Amazon ECR | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@v1 | |
- name: "Build & Push Backend Docker Image" | |
env: | |
GIT_TAG: ${{ github.ref_name }} | |
AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }} | |
run: | | |
TAG="${GIT_TAG##*/}" | |
IMAGE_URI=${AWS_ACCOUNT_ID}.dkr.ecr.us-east-1.amazonaws.com/backend | |
docker build \ | |
--build-arg SOURCE_TAG=$TAG \ | |
--target prod \ | |
-t $IMAGE_URI:$TAG \ | |
-t $IMAGE_URI:latest \ | |
./backend | |
docker push --all-tags $IMAGE_URI |