From 1d92f09a380bfab6b0cc37fb2c30a1aceb16b8a0 Mon Sep 17 00:00:00 2001 From: "Mahadik, Mukul Chandrakant" Date: Mon, 7 Oct 2024 22:26:35 -0700 Subject: [PATCH] Cleaned up code --- .github/workflows/image_build_push.yml | 14 -------- .../workflows/reusable_image_build_push.yml | 36 ------------------- 2 files changed, 50 deletions(-) diff --git a/.github/workflows/image_build_push.yml b/.github/workflows/image_build_push.yml index cdc4a5970..cf8b9fd7a 100644 --- a/.github/workflows/image_build_push.yml +++ b/.github/workflows/image_build_push.yml @@ -3,8 +3,6 @@ name: docker image on: push: branches: [ master, gis-based-mode-detection, cleanup-cicd ] - # tags: - # - "v[0-9]+.[0-9]+.[0-9]+" release: types: [published] @@ -33,14 +31,6 @@ jobs: env: RUNNER_CONTEXT: ${{ toJson(runner) }} run: echo "$RUNNER_CONTEXT" - - name: Dump strategy context - env: - STRATEGY_CONTEXT: ${{ toJson(strategy) }} - run: echo "$STRATEGY_CONTEXT" - - name: Dump matrix context - env: - MATRIX_CONTEXT: ${{ toJson(matrix) }} - run: echo "$MATRIX_CONTEXT" debug-info: runs-on: ubuntu-latest @@ -74,9 +64,6 @@ jobs: id: get-branch-name run: | if [ "${{ github.ref_type }}" == "tag" ]; then - # base_ref=${{ github.event.base_ref }} - # echo "Branch name: branch_name=${base_ref#refs/heads/}" - # echo "branch_name=${base_ref#refs/heads/}" >> "$GITHUB_OUTPUT" target_branch=${{ github.event.release.target_commitish }} echo "branch_name=${target_branch}" >> "$GITHUB_OUTPUT" elif [ "${{ github.ref_type }}" == "branch" ]; then @@ -84,7 +71,6 @@ 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') }} 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 diff --git a/.github/workflows/reusable_image_build_push.yml b/.github/workflows/reusable_image_build_push.yml index b26b79642..5e2c616c2 100644 --- a/.github/workflows/reusable_image_build_push.yml +++ b/.github/workflows/reusable_image_build_push.yml @@ -157,19 +157,15 @@ jobs: 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 }}" 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 echo "Current admin-dash image tag: ${{ steps.set-tags.outputs.ADMIN_DASH_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 }}" elif [ "${{ inputs.repo }}" = "em-public-dashboard" ]; then 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 - name: docker login @@ -187,7 +183,6 @@ jobs: run: | if [ "${{ inputs.repo }}" = "e-mission-server" ]; then docker build -t $DOCKER_USER/${{ inputs.repo }}:${{ steps.fetch-latest-release-tags.outputs.tag_name }} . - # docker build -t $DOCKER_USER/${{ inputs.repo }}:${{ inputs.branch }}_${{ steps.fetch-latest-release-tags.outputs.tag_name }} . elif [ "${{ inputs.repo }}" = "nrel-openpath-join-page" ]; then if [ "${{ github.event_name }}" == "release" ]; then docker build -t $DOCKER_USER/${{ inputs.repo }}:${{ steps.fetch-latest-release-tags.outputs.tag_name }} ./frontend @@ -207,20 +202,15 @@ jobs: if [ "${{ inputs.repo }}" = "op-admin-dashboard" ]; then if [ "${{ github.event_name }}" == "release" ]; then docker image tag e-mission/opdash:0.0.1 $DOCKER_USER/${{ inputs.repo }}:${{ steps.fetch-latest-release-tags.outputs.tag_name }} - # docker image tag e-mission/opdash:0.0.1 $DOCKER_USER/${{ inputs.repo }}:${{ inputs.branch }}_${{ steps.fetch-latest-release-tags.outputs.tag_name }} elif [ "${{ github.event_name }}" == "workflow_dispatch" ]; then docker image tag e-mission/opdash:0.0.1 $DOCKER_USER/${{ inputs.repo }}:${{ steps.increment-release-tag.outputs.new_repo_version }} - # docker image tag e-mission/opdash:0.0.1 $DOCKER_USER/${{ inputs.repo }}:${{ inputs.branch }}_${{ steps.increment-release-tag.outputs.new_repo_version }} fi elif [ "${{ inputs.repo }}" = "em-public-dashboard" ]; then if [ "${{ github.event_name }}" == "release" ]; then docker image tag em-pub-dash-prod/frontend:latest $DOCKER_USER/${{ inputs.repo }}_frontend:${{ steps.fetch-latest-release-tags.outputs.tag_name }} docker image tag em-pub-dash-prod/viz-scripts:latest $DOCKER_USER/${{ inputs.repo }}_notebook:${{ steps.fetch-latest-release-tags.outputs.tag_name }} - # docker image tag em-pub-dash-prod/frontend:latest $DOCKER_USER/${{ inputs.repo }}_frontend:${{ inputs.branch }}_${{ steps.fetch-latest-release-tags.outputs.tag_name }} - # docker image tag em-pub-dash-prod/viz-scripts:latest $DOCKER_USER/${{ inputs.repo }}_notebook:${{ inputs.branch }}_${{ steps.fetch-latest-release-tags.outputs.tag_name }} elif [ "${{ github.event_name }}" == "workflow_dispatch" ]; then docker image tag em-pub-dash-prod/viz-scripts:latest $DOCKER_USER/${{ inputs.repo }}_notebook:${{ steps.increment-release-tag.outputs.new_repo_version }} - # docker image tag em-pub-dash-prod/viz-scripts:latest $DOCKER_USER/${{ inputs.repo }}_notebook:${{ inputs.branch }}_${{ steps.increment-release-tag.outputs.new_repo_version }} fi fi @@ -231,23 +221,17 @@ jobs: if [ "${{ github.event_name }}" == "release" ]; then docker push $DOCKER_USER/${{ inputs.repo }}_frontend:${{ steps.fetch-latest-release-tags.outputs.tag_name }} docker push $DOCKER_USER/${{ inputs.repo }}_notebook:${{ steps.fetch-latest-release-tags.outputs.tag_name }} - # docker push $DOCKER_USER/${{ inputs.repo }}_frontend:${{ inputs.branch }}_${{ steps.fetch-latest-release-tags.outputs.tag_name }} - # docker push $DOCKER_USER/${{ inputs.repo }}_notebook:${{ inputs.branch }}_${{ steps.fetch-latest-release-tags.outputs.tag_name }} elif [ "${{ github.event_name }}" == "workflow_dispatch" ]; then docker push $DOCKER_USER/${{ inputs.repo }}_notebook:${{ steps.increment-release-tag.outputs.new_repo_version }} - # docker push $DOCKER_USER/${{ inputs.repo }}_notebook:${{ inputs.branch }}_${{ steps.increment-release-tag.outputs.new_repo_version }} fi elif [ "${{ inputs.repo }}" = "op-admin-dashboard" ] || [ "${{ inputs.repo }}" = "nrel-openpath-join-page" ]; then if [ "${{ github.event_name }}" == "release" ]; then docker push $DOCKER_USER/${{ inputs.repo }}:${{ steps.fetch-latest-release-tags.outputs.tag_name }} - # docker push $DOCKER_USER/${{ inputs.repo }}:${{ inputs.branch }}_${{ steps.fetch-latest-release-tags.outputs.tag_name }} elif [ "${{ github.event_name }}" == "workflow_dispatch" ]; then docker push $DOCKER_USER/${{ inputs.repo }}:${{ steps.increment-release-tag.outputs.new_repo_version }} - # docker push $DOCKER_USER/${{ inputs.repo }}:${{ inputs.branch }}_${{ steps.increment-release-tag.outputs.new_repo_version }} fi else docker push $DOCKER_USER/${{ inputs.repo }}:${{ steps.fetch-latest-release-tags.outputs.tag_name }} - # docker push $DOCKER_USER/${{ inputs.repo }}:${{ inputs.branch }}_${{ steps.fetch-latest-release-tags.outputs.tag_name }} fi - name: Update .env file @@ -255,34 +239,24 @@ jobs: run: | if [ "${{ inputs.repo }}" = "e-mission-server" ]; then echo "SERVER_IMAGE_TAG=${{ steps.fetch-latest-release-tags.outputs.tag_name }}" > .env - # echo "SERVER_IMAGE_TAG=${{ inputs.branch }}_${{ steps.fetch-latest-release-tags.outputs.tag_name }}" > .env elif [ "${{ inputs.repo }}" = "nrel-openpath-join-page" ]; then if [ "${{ github.event_name }}" == "release" ]; then echo "JOIN_IMAGE_TAG=${{ steps.fetch-latest-release-tags.outputs.tag_name }}" > .env - # echo "JOIN_IMAGE_TAG=${{ inputs.branch }}_${{ steps.fetch-latest-release-tags.outputs.tag_name }}" > .env elif [ "${{ github.event_name }}" == "workflow_dispatch" ]; then echo "JOIN_IMAGE_TAG=${{ steps.increment-release-tag.outputs.new_repo_version }}" > .env - # echo "JOIN_IMAGE_TAG=${{ inputs.branch }}_${{ steps.increment-release-tag.outputs.new_repo_version }}" > .env fi elif [ "${{ inputs.repo }}" = "op-admin-dashboard" ]; then if [ "${{ github.event_name }}" == "release" ]; then echo "ADMIN_DASH_IMAGE_TAG=${{ steps.fetch-latest-release-tags.outputs.tag_name }}" > .env - # echo "ADMIN_DASH_IMAGE_TAG=${{ inputs.branch }}_${{ steps.fetch-latest-release-tags.outputs.tag_name }}" > .env elif [ "${{ github.event_name }}" == "workflow_dispatch" ]; then echo "ADMIN_DASH_IMAGE_TAG=${{ steps.increment-release-tag.outputs.new_repo_version }}" > .env - # echo "ADMIN_DASH_IMAGE_TAG=${{ inputs.branch }}_${{ steps.increment-release-tag.outputs.new_repo_version }}" > .env fi echo "SERVER_IMAGE_TAG=${{ steps.get-server-tag.outputs.SERVER_IMAGE_TAG }}" >> .env elif [ "${{ inputs.repo }}" = "em-public-dashboard" ]; then if [ "${{ github.event_name }}" == "release" ]; then - echo "Release event: Update frontend image tag" echo "PUBLIC_DASH_NOTEBOOK_IMAGE_TAG=${{ steps.fetch-latest-release-tags.outputs.tag_name }}" > .env echo "PUBLIC_DASH_FRONTEND_IMAGE_TAG=${{ steps.fetch-latest-release-tags.outputs.tag_name }}" >> .env - # echo "PUBLIC_DASH_NOTEBOOK_IMAGE_TAG=${{ inputs.branch }}_${{ steps.fetch-latest-release-tags.outputs.tag_name }}" > .env - # echo "PUBLIC_DASH_FRONTEND_IMAGE_TAG=${{ inputs.branch }}_${{ steps.fetch-latest-release-tags.outputs.tag_name }}" >> .env elif [ "${{ github.event_name }}" == "workflow_dispatch" ]; then - echo "Workflow_dispatch: Reuse existing frontend image tag" - # echo "PUBLIC_DASH_NOTEBOOK_IMAGE_TAG=${{ inputs.branch }}_${{ steps.increment-release-tag.outputs.new_repo_version }}" > .env echo "PUBLIC_DASH_NOTEBOOK_IMAGE_TAG=${{ steps.increment-release-tag.outputs.new_repo_version }}" > .env echo "PUBLIC_DASH_FRONTEND_IMAGE_TAG=${{ steps.set-tags.outputs.PUBLIC_DASH_FRONTEND_IMAGE_TAG }}" >> .env fi @@ -309,16 +283,6 @@ jobs: https://api.github.com/repos/MukuFlash03/${{ inputs.repo }}/releases \ -d '{"tag_name":"${{ steps.increment-release-tag.outputs.new_repo_version }}","target_commitish":"${{ inputs.branch }}","name":"${{ steps.increment-release-tag.outputs.new_repo_version }}","body":"Triggered on e-mission-server new release. Bumping up release version.","generate_release_notes":true}' - echo "Logging latest created release" - - latest_release=$(curl -L \ - -H "Accept: application/vnd.github+json" \ - -H "Authorization: Bearer ${{ secrets.GH_FG_PAT_TAGS }}" \ - -H "X-GitHub-Api-Version: 2022-11-28" \ - https://api.github.com/repos/MukuFlash03/${{ inputs.repo }}/releases/latest) - - echo $latest_release - - name: Add, Commit, Push changes to .env file if: ${{ github.ref_type == 'tag' || github.event_name == 'workflow_dispatch' }} run: |