[5] 도커 이미지를 ECR로 push하기

hyuckhoon.ko·2021년 4월 7일
0

What I learned in first year

목록 보기
126/146

name: CI on ECR for koodon-backend celery-server

on: [push, pull_request]

jobs:
  deploy:
    name: Deploy
    runs-on: ubuntu-latest

    steps:
      - 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: ap-northeast-2

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

      - name: Checkout
        uses: actions/checkout@v1 
          
      - name: Build, tag, and push image to Amazon ECR
        id: build-image
        env:
          # ECR_REGISTRY: ${{ secrets.REGISTRY }}
          ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
          ECR_REPOSITORY: backend_async_server
          IMAGE_TAG: latest
        run: |
          # Build a docker image and push it to ECR
          docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
          echo "Pushing image to ECR..."
          docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
          echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG"

0개의 댓글