dev: modified the branch wise build (#2702)

* cherrypicked branch build code

* trigger on pull request

* branch filter

* checking branch filter

* checking push

* checking push again

* code cleanup before PR
This commit is contained in:
Manish Gupta 2023-11-07 17:23:32 +05:30 committed by GitHub
parent 26de35bd8d
commit 1412c1c94a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,33 +1,46 @@
name: Docker Branch Build name: Branch Build
on: on:
workflow_dispatch: push:
inputs: branches:
logLevel: - master
description: 'Log level' - release
required: true - qa
default: 'warning' - develop
tags: pull_request:
description: 'Dev/QA Builds' types:
- closed
branches:
- master
- release
- qa
- develop
env: env:
gh_branch: ${{ github.ref_name }} TARGET_BRANCH: ''
img_tag: latest
jobs: jobs:
branch_build_and_push: branch_build_and_push:
if: ${{ (github.event_name == 'push') || (github.event_name == 'pull_request' && github.event.action =='closed' && github.event.pull_request.merged == true) }}
name: Build-Push Web/Space/API/Proxy Docker Image name: Build-Push Web/Space/API/Proxy Docker Image
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
steps: steps:
- name: Check out the repo - name: Check out the repo
uses: actions/checkout@v3.3.0 uses: actions/checkout@v3.3.0
- name: Set Target Branch Name on PR close
if: ${{ github.event_name == 'pull_request' && github.event.action =='closed' }}
run: echo "TARGET_BRANCH=${{ github.event.pull_request.base.ref }}" >> $GITHUB_ENV
- name: Set Target Branch Name on other than PR close
if: ${{ github.event_name == 'push' }}
run: echo "TARGET_BRANCH=${{ github.ref_name }}" >> $GITHUB_ENV
- uses: ASzc/change-string-case-action@v2 - uses: ASzc/change-string-case-action@v2
id: gh_branch_upper_lower id: gh_branch_upper_lower
with: with:
string: ${{ env.gh_branch }} string: ${{env.TARGET_BRANCH}}
- uses: mad9000/actions-find-and-replace-string@2 - uses: mad9000/actions-find-and-replace-string@2
id: gh_branch_replace_slash id: gh_branch_replace_slash
@ -111,7 +124,7 @@ jobs:
env: env:
DOCKER_BUILDKIT: 1 DOCKER_BUILDKIT: 1
DOCKER_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} DOCKER_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKET_PASSWORD: ${{ secrets.DOCKERHUB_TOKEN }} DOCKER_PASSWORD: ${{ secrets.DOCKERHUB_TOKEN }}
branch_build_push_space: branch_build_push_space:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
@ -141,7 +154,7 @@ jobs:
env: env:
DOCKER_BUILDKIT: 1 DOCKER_BUILDKIT: 1
DOCKER_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} DOCKER_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKET_PASSWORD: ${{ secrets.DOCKERHUB_TOKEN }} DOCKER_PASSWORD: ${{ secrets.DOCKERHUB_TOKEN }}
branch_build_push_backend: branch_build_push_backend:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
@ -171,7 +184,7 @@ jobs:
env: env:
DOCKER_BUILDKIT: 1 DOCKER_BUILDKIT: 1
DOCKER_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} DOCKER_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKET_PASSWORD: ${{ secrets.DOCKERHUB_TOKEN }} DOCKER_PASSWORD: ${{ secrets.DOCKERHUB_TOKEN }}
branch_build_push_proxy: branch_build_push_proxy:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
@ -202,4 +215,4 @@ jobs:
env: env:
DOCKER_BUILDKIT: 1 DOCKER_BUILDKIT: 1
DOCKER_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} DOCKER_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKET_PASSWORD: ${{ secrets.DOCKERHUB_TOKEN }} DOCKER_PASSWORD: ${{ secrets.DOCKERHUB_TOKEN }}