-
Notifications
You must be signed in to change notification settings - Fork 0
35 lines (28 loc) · 1.13 KB
/
ecr-deploy.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
name: Git Common Flow
on: workflow_call
env:
AWS_REGION: us-west-2 # 원하는 AWS 리전을 설정하세요
ECR_REPOSITORY: my-ecr-repo # ECR 리포지토리 이름
jobs:
push-to-ecr:
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Amazon ECR
uses: aws-actions/amazon-ecr-login@v1
with:
registry: ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ env.AWS_REGION }}.amazonaws.com
- name: Build and Push Docker image
run: |
IMAGE_TAG=${{ github.sha }}
if [[ ${{ github.ref }} == 'refs/heads/develop' ]]; then
IMAGE_TAG="develop"
elif [[ ${{ github.ref }} == 'refs/heads/master' ]]; then
IMAGE_TAG="product"
fi
docker buildx build --platform linux/amd64 -t ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ env.AWS_REGION }}.amazonaws.com/${{ env.ECR_REPOSITORY }}:$IMAGE_TAG .
docker push ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ env.AWS_REGION }}.amazonaws.com/${{ env.ECR_REPOSITORY }}:$IMAGE_TAG