Skip to content

Commit

Permalink
add workflows: build & push docker image to ECR
Browse files Browse the repository at this point in the history
  • Loading branch information
leobang17 committed Apr 25, 2024
1 parent 53ca8e0 commit 08c267a
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/push-image-to-ecr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Push application image to ECR

on:
push:
branches:
- main

jobs:
build-and-push:
name: Build and Push Docker image to ECR
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}

- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2

- name: Build, tag, and push image to Amazon ECR
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: ${{ secrets.ECR_REPOSITORY }}
IMAGE_TAG: latest
run: |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG

0 comments on commit 08c267a

Please sign in to comment.