From 8b123afbd2c8b4fb4bacf7fb628512384ba38d17 Mon Sep 17 00:00:00 2001 From: hendisantika Date: Wed, 13 Mar 2024 09:24:29 +0700 Subject: [PATCH] =?UTF-8?q?#148=20-=20Setup=20CI/CD=20:seven:=20?= =?UTF-8?q?=F0=9F=AB=B8=F0=9F=8C=80=E2=9C=8F=EF=B8=8F=F0=9F=93=97=20:octoc?= =?UTF-8?q?at:=F0=9F=90=A7=F0=9F=90=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy_via_ecr.yml | 39 ++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/.github/workflows/deploy_via_ecr.yml b/.github/workflows/deploy_via_ecr.yml index 0d6cb0d..719fb35 100644 --- a/.github/workflows/deploy_via_ecr.yml +++ b/.github/workflows/deploy_via_ecr.yml @@ -44,6 +44,7 @@ jobs: - name: Checkout uses: actions/checkout@v4 + # - run: docker build --tag hikaricp:$IMAGE_TAG . - name: Set up QEMU uses: docker/setup-qemu-action@v3 @@ -51,18 +52,34 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - - name: Push to ECR - env: - ECR_REGISTRY: ${{ steps.login-pf-aws-ecr.outputs.registry }} - ECR_REPOSITORY: ${{secrets.AWS_ECR_REPO}} - IMAGE_TAG: ${{ github.run_number }} - id: ecr - uses: jwalton/gh-ecr-push@v1 + - name: Scrape build info + run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV + + - name: Build and push + uses: docker/build-push-action@v5 with: - access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} - secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - region: ${{ secrets.AWS_REGION }} - image: hikaricp:$IMAGE_TAG + context: . + file: Dockerfile + push: true + labels: ${{ steps.meta.outputs.labels }} + tags: ${{secrets.AWS_ECR_REPO}}/hikaricp:${{ github.run_number }} + build-args: | + GIT_VERSION_TAG=${{ env.RELEASE_VERSION }} + GIT_COMMIT_MESSAGE=${{ github.event.head_commit.message }} + GIT_VERSION_HASH=${{ github.sha }} + + # - name: Push to ECR + # env: + # ECR_REGISTRY: ${{ steps.login-pf-aws-ecr.outputs.registry }} + # ECR_REPOSITORY: ${{secrets.AWS_ECR_REPO}} + # IMAGE_TAG: ${{ github.run_number }} + # id: ecr + # uses: jwalton/gh-ecr-push@v1 + # with: + # access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + # secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + # region: ${{ secrets.AWS_REGION }} + # image: hikaricp:$IMAGE_TAG deploy: needs: push-to-ecr