From c5a13e335c4c9c089161e75be990877fd220d59f Mon Sep 17 00:00:00 2001 From: Nam Gi Beom Date: Thu, 8 Feb 2024 08:59:16 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20ECR=20login=20step=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy-fluentbit.yml | 36 ++++++++++++++++++++----- .github/workflows/push-image.yml | 37 -------------------------- 2 files changed, 29 insertions(+), 44 deletions(-) delete mode 100644 .github/workflows/push-image.yml diff --git a/.github/workflows/deploy-fluentbit.yml b/.github/workflows/deploy-fluentbit.yml index bd75d29..9794e76 100644 --- a/.github/workflows/deploy-fluentbit.yml +++ b/.github/workflows/deploy-fluentbit.yml @@ -19,17 +19,33 @@ env: TAG: latest jobs: + login-ecr: + runs-on: ubuntu-latest + steps: + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v2 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }} + 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 + with: + mask-password: 'true' + deploy-dev: runs-on: ubuntu-latest steps: - name: Check out code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - - name: Push image to Amazon ECR - uses: ./.github/workflows/push-image.yml - with: - uri: ${{ env.ENDPOINT }}/${{ env.DEV_REPO }}:${{ env.TAG }} - working-directory: ./fluentbit + - name: Build and push image to Amazon ECR + run: | + docker build -t ${{ env.ENDPOINT }}/${{ env.DEV_REPO }}:${{ env.TAG }} . + docker push ${{ env.ENDPOINT }}/${{ env.DEV_REPO }}:${{ env.TAG }} + working-directory: ./fluentbit - name: Pull image from Amazon ECR and restart container in EC2 uses: appleboy/ssh-action@master @@ -47,7 +63,13 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out code - uses: actions/checkout@v3 + uses: actions/checkout@v4 + + - name: Build and push image to Amazon ECR + run: | + docker build -t ${{ env.ENDPOINT }}/${{ env.PROD_REPO }}:${{ env.TAG }} . + docker push ${{ env.ENDPOINT }}/${{ env.PROD_REPO }}:${{ env.TAG }} + working-directory: ./fluentbit - name: Push image to Amazon ECR uses: ./.github/workflows/push-image.yml diff --git a/.github/workflows/push-image.yml b/.github/workflows/push-image.yml deleted file mode 100644 index d650854..0000000 --- a/.github/workflows/push-image.yml +++ /dev/null @@ -1,37 +0,0 @@ -name: AWS ECR Login and Push Image - -on: - workflow_call: - inputs: - uri: - description: 'URI of the repository' - required: true - type: string - working-directory: - description: 'Working directory' - required: true - type: string - - -jobs: - push-image: - runs-on: ubuntu-latest - steps: - - name: Configure AWS credentials - uses: aws-actions/configure-aws-credentials@v2 - with: - aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }} - aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - aws-region: ap-northeast-2 - - - name: login to ECR - id: login-ecr - uses: aws-actions/amazon-ecr-login@v1 - with: - mask-password: 'true' - - - name: Build and push image to Amazon ECR - run: | - docker build -t ${{ inputs.uri}} . - docker push ${{ inputs.uri}} - working-directory: ${{ inputs.working-directory }} \ No newline at end of file