[ECR] build & push v0.5.0 #52
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] build & push backend image' | |
run-name: '[ECR] build & push ${{ github.ref_name }}' | |
on: | |
push: | |
tags: | |
- "v*.*.*" | |
jobs: | |
build_and_push: | |
name: "Build Backend Image From Git Tag" | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.ref_name }} | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
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@v2 | |
- name: "Build & Push Backend Docker Image" | |
env: | |
AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }} | |
DOCKER_BUILDKIT: '1' | |
APP_NAME: ${{ secrets.APP_NAME }} | |
run: | | |
IMAGE_URI=${AWS_ACCOUNT_ID}.dkr.ecr.us-east-1.amazonaws.com/${APP_NAME}-backend | |
docker build \ | |
--build-arg SOURCE_TAG=${{ github.ref_name }} \ | |
--target prod \ | |
-t $IMAGE_URI:${{ github.ref_name }} \ | |
-t $IMAGE_URI:latest \ | |
./backend | |
docker push --all-tags $IMAGE_URI |