From 804a61d2d5d6fcc803bcf87063de73bf2984947f Mon Sep 17 00:00:00 2001 From: "Mahadik, Mukul Chandrakant" Date: Mon, 7 Oct 2024 09:46:46 -0700 Subject: [PATCH] Server: Building image for both push:branch and push:tags For server, running build job on both push:branch and push:tags. - It might happen that the Dockerfile was changed or any script used in the Dockerfile and the build fails. - Right now the build + push step is combined in the reusable workflow and both would only run if event was push:tags. - Hence we would already have created a new release and then found out that the build failed. - So for server, along with tests, also running the reusable workflow unto the build step. - Then, will only run the remaining steps on push:tags event: Docker rename + push, .env file update + commit/push; --- .github/workflows/image_build_push.yml | 3 ++- .github/workflows/reusable_image_build_push.yml | 14 +++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/.github/workflows/image_build_push.yml b/.github/workflows/image_build_push.yml index 4b91e582a..b19d81285 100644 --- a/.github/workflows/image_build_push.yml +++ b/.github/workflows/image_build_push.yml @@ -80,7 +80,8 @@ jobs: fi build: - if: ${{ !contains(github.event.head_commit.author.name, 'Github Actions bot to update .env with latest tags') && github.ref_type == 'tag' }} + # if: ${{ !contains(github.event.head_commit.author.name, 'Github Actions bot to update .env with latest tags') && github.ref_type == 'tag' }} + if: ${{ !contains(github.event.head_commit.author.name, 'Github Actions bot to update .env with latest tags') }} needs: [test-with-docker, test-with-manual-install, get-branch-name] uses: MukuFlash03/e-mission-server/.github/workflows/reusable_image_build_push.yml@cleanup-cicd with: diff --git a/.github/workflows/reusable_image_build_push.yml b/.github/workflows/reusable_image_build_push.yml index 4dbacf5b8..30b239053 100644 --- a/.github/workflows/reusable_image_build_push.yml +++ b/.github/workflows/reusable_image_build_push.yml @@ -152,11 +152,11 @@ jobs: - name: Print input docker image tags run: | - echo "Event name: ${{ github.event_name }}" + echo "Event name: ${{ github.event_name }} | ${{ github.ref_type }}" if [ "${{ inputs.repo }}" = "e-mission-server" ]; then echo "Current server image tag: ${{ steps.set-tags.outputs.SERVER_IMAGE_TAG }}" - echo "Current server image tag version: ${{ steps.get-server-tag.outputs.SERVER_IMAGE_TAG }}" - echo "Current server image target commitish: ${{ steps.get-server-tag.outputs.SERVER_IMAGE_TARGET }}" + # echo "Current server image tag version: ${{ steps.get-server-tag.outputs.SERVER_IMAGE_TAG }}" + # echo "Current server image target commitish: ${{ steps.get-server-tag.outputs.SERVER_IMAGE_TARGET }}" elif [ "${{ inputs.repo }}" = "nrel-openpath-join-page" ]; then echo "Current join-page image tag: ${{ steps.set-tags.outputs.JOIN_IMAGE_TAG }}" elif [ "${{ inputs.repo }}" = "op-admin-dashboard" ]; then @@ -164,8 +164,8 @@ jobs: echo "Latest server image tag (${{ github.event_name }}): ${{ steps.get-server-tag.outputs.SERVER_IMAGE_TAG }}" # echo "Latest server image target commitish: ${{ steps.get-server-tag.outputs.SERVER_IMAGE_TARGET }}" elif [ "${{ inputs.repo }}" = "em-public-dashboard" ]; then - echo "Current notebook image tag (push): ${{ steps.set-tags.outputs.PUBLIC_DASH_NOTEBOOK_IMAGE_TAG }}" - echo "Current frontend image tag (push): ${{ steps.set-tags.outputs.PUBLIC_DASH_FRONTEND_IMAGE_TAG }}" + echo "Current notebook image tag: ${{ steps.set-tags.outputs.PUBLIC_DASH_NOTEBOOK_IMAGE_TAG }}" + echo "Current frontend image tag: ${{ steps.set-tags.outputs.PUBLIC_DASH_FRONTEND_IMAGE_TAG }}" echo "Latest server image tag (${{ github.event_name }}): ${{ steps.get-server-tag.outputs.SERVER_IMAGE_TAG }}" # echo "Latest server image target commitish: ${{ steps.get-server-tag.outputs.SERVER_IMAGE_TARGET }}" fi @@ -200,6 +200,7 @@ jobs: docker images - name: rename docker image + if: ${{ github.ref_type == 'tag' }} run: | if [ "${{ inputs.repo }}" = "op-admin-dashboard" ]; then if [ "${{ github.event_name }}" == "push" ]; then @@ -222,6 +223,7 @@ jobs: fi - name: push docker image + if: ${{ github.ref_type == 'tag' }} run: | if [ "${{ inputs.repo }}" = "em-public-dashboard" ]; then if [ "${{ github.event_name }}" == "push" ]; then @@ -247,6 +249,7 @@ jobs: fi - name: Update .env file + if: ${{ github.ref_type == 'tag' }} run: | if [ "${{ inputs.repo }}" = "e-mission-server" ]; then echo "SERVER_IMAGE_TAG=${{ steps.fetch-latest-release-tags.outputs.tag_name }}" > .env @@ -286,6 +289,7 @@ jobs: cat .env - name: Add, Commit, Push changes to .env file + if: ${{ github.ref_type == 'tag' }} run: | git config --local user.email "action@github.com" git config --local user.name "Github Actions bot to update .env with latest tags"