From 7feb75f98b42a4ca263761e18115bac96164b8a3 Mon Sep 17 00:00:00 2001 From: Nipun Arora Date: Tue, 5 Mar 2024 15:05:23 +0530 Subject: [PATCH] Update mfe-workbench-web-docker.yml --- .../workflows/mfe-workbench-web-docker.yml | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/.github/workflows/mfe-workbench-web-docker.yml b/.github/workflows/mfe-workbench-web-docker.yml index 77d0fc9e6d8..f16a5b7806b 100644 --- a/.github/workflows/mfe-workbench-web-docker.yml +++ b/.github/workflows/mfe-workbench-web-docker.yml @@ -2,7 +2,7 @@ name: workbench ui service docker Image CI on: push: - branches: [ "mf-build-docker", "mf-stable","mf-stable-common-module" ] + branches: [ "mf-build-docker","mf-stable-common-module" ] pull_request: branches: [ "mf-build" ] @@ -14,19 +14,36 @@ jobs: steps: - uses: actions/checkout@v3 + with: + fetch-depth: 0 # Fetch all history for tags and branches + + - name: Set up environment variables + id: env + run: | + echo "BRANCH_NAME=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV + echo "ACTION_NUMBER=${GITHUB_RUN_NUMBER}" >> $GITHUB_ENV + echo "COMMIT_ID=${GITHUB_SHA: -8}" >> $GITHUB_ENV # Extract last 8 characters of SHA + - name: Build the Docker image + id: docker_build working-directory: ./micro-ui/web/packages/workbench - run: docker build . --file docker/Dockerfile --tag egovio/workbench-mfe:latest + run: | + IMAGE_TAG=egovio/workbench-mfe:${{ env.BRANCH_NAME }}-${{ env.COMMIT_ID }}-${{ env.ACTION_NUMBER }} + docker build . \ + --file docker/Dockerfile \ + --tag $IMAGE_TAG + echo "::set-output name=image_name::$IMAGE_TAG" - name: Login to Docker Hub and Push Docker Image working-directory: ./micro-ui/web/packages/workbench env: DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} + IMAGE_NAME: ${{ steps.docker_build.outputs.image_name }} run: | # Authenticate with Docker Hub echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin # Push the image to Docker Hub - docker push egovio/workbench-mfe:latest - + docker push $IMAGE_NAME + echo "Docker image pushed: $IMAGE_NAME"