From b024163c8cbb7ef8b81e4f8bfed9a95616f986d3 Mon Sep 17 00:00:00 2001 From: Ajit Padhi Date: Thu, 5 Dec 2024 14:48:37 +0530 Subject: [PATCH 1/8] updated workflow --- .github/workflows/build-docker-images.yml | 6 ++++++ .github/workflows/tests.yml | 16 ++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/.github/workflows/build-docker-images.yml b/.github/workflows/build-docker-images.yml index 1ab28710f..566dd4f2f 100644 --- a/.github/workflows/build-docker-images.yml +++ b/.github/workflows/build-docker-images.yml @@ -19,6 +19,11 @@ on: - reopened - synchronize merge_group: + workflow_dispatch: + inputs: + branch_name: + description: 'Branch name' + required: true jobs: test-job: @@ -30,6 +35,7 @@ jobs: ref: ${{ github.event.workflow_run.head_branch }} - run: git branch - run: env + - run: echo "branch.....${{github.event.inputs.branch_name}}"" docker-build: if: ${{ github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success' }} diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 52804657b..9dda50884 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -97,3 +97,19 @@ jobs: run: make unittest-frontend - name: Lint run: make lint + - name: Trigger Build Docker Images Workflow + uses: actions/github-script@v7 + with: + script: | + const response = await github.actions.createWorkflowDispatch({ + owner: context.repo.owner, + repo: context.repo.repo, + workflow_id: 'build-docker-images.yml', + ref: github.ref, + inputs: { + branch_name: github.ref.replace('refs/heads/', '') + } + }); + console.log(response); + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 02f171b2c110e8a08ccc2830c3823c78947c949c Mon Sep 17 00:00:00 2001 From: Ajit Padhi Date: Thu, 5 Dec 2024 14:51:13 +0530 Subject: [PATCH 2/8] updated workflow --- .github/workflows/build-docker-images.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-docker-images.yml b/.github/workflows/build-docker-images.yml index 566dd4f2f..b2c9e84a6 100644 --- a/.github/workflows/build-docker-images.yml +++ b/.github/workflows/build-docker-images.yml @@ -32,10 +32,10 @@ jobs: steps: - uses: actions/checkout@v4 with: - ref: ${{ github.event.workflow_run.head_branch }} + ref: ${{ github.event.inputs.branch_name }} - run: git branch - run: env - - run: echo "branch.....${{github.event.inputs.branch_name}}"" + - run: echo "branch... ${{github.event.inputs.branch_name}}" docker-build: if: ${{ github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success' }} From 055fa95c768bf893ef8f4a69a1e4bc8c96b2f07e Mon Sep 17 00:00:00 2001 From: Ajit Padhi Date: Thu, 5 Dec 2024 14:56:50 +0530 Subject: [PATCH 3/8] updated workflow --- .github/workflows/build-docker-images.yml | 4 +++- .github/workflows/tests.yml | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-docker-images.yml b/.github/workflows/build-docker-images.yml index b2c9e84a6..d0c629fc7 100644 --- a/.github/workflows/build-docker-images.yml +++ b/.github/workflows/build-docker-images.yml @@ -35,7 +35,9 @@ jobs: ref: ${{ github.event.inputs.branch_name }} - run: git branch - run: env - - run: echo "branch... ${{github.event.inputs.branch_name}}" + - name: Get branch ... + run: | + echo "Input branch ${{github.event.inputs.branch_name}}" docker-build: if: ${{ github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success' }} diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 9dda50884..2e9049d07 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -101,13 +101,14 @@ jobs: uses: actions/github-script@v7 with: script: | + const branchName = process.env.GITHUB_REF.replace('refs/heads/', ''); const response = await github.actions.createWorkflowDispatch({ owner: context.repo.owner, repo: context.repo.repo, workflow_id: 'build-docker-images.yml', ref: github.ref, inputs: { - branch_name: github.ref.replace('refs/heads/', '') + branch_name: branchName } }); console.log(response); From 9cab293dc5340aa17eb98a7a0a66683a26a086c5 Mon Sep 17 00:00:00 2001 From: Ajit Padhi Date: Thu, 5 Dec 2024 15:12:23 +0530 Subject: [PATCH 4/8] updated workflow --- .github/workflows/build-docker-images.yml | 10 ++++++---- .github/workflows/tests.yml | 21 ++++++--------------- 2 files changed, 12 insertions(+), 19 deletions(-) diff --git a/.github/workflows/build-docker-images.yml b/.github/workflows/build-docker-images.yml index d0c629fc7..340ae5496 100644 --- a/.github/workflows/build-docker-images.yml +++ b/.github/workflows/build-docker-images.yml @@ -19,7 +19,7 @@ on: - reopened - synchronize merge_group: - workflow_dispatch: + workflow_dispatch: # Allow manual triggering inputs: branch_name: description: 'Branch name' @@ -35,9 +35,11 @@ jobs: ref: ${{ github.event.inputs.branch_name }} - run: git branch - run: env - - name: Get branch ... - run: | - echo "Input branch ${{github.event.inputs.branch_name}}" + - name: Print Debug Info + run: | + echo "Event Name: ${{ github.event_name }}" + echo "Workflow Conclusion: ${{ github.event.workflow_run.conclusion }}" + echo "Branch Name: ${{ github.event.inputs.branch_name || env.BRANCH_NAME }}" docker-build: if: ${{ github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success' }} diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 2e9049d07..042316165 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -97,20 +97,11 @@ jobs: run: make unittest-frontend - name: Lint run: make lint + - name: Install GitHub CLI + run: sudo apt-get install gh + - name: Set GH_TOKEN + run: echo "GH_TOKEN=${{ secrets.GITHUB_TOKEN }}" >> $GITHUB_ENV - name: Trigger Build Docker Images Workflow - uses: actions/github-script@v7 - with: - script: | - const branchName = process.env.GITHUB_REF.replace('refs/heads/', ''); - const response = await github.actions.createWorkflowDispatch({ - owner: context.repo.owner, - repo: context.repo.repo, - workflow_id: 'build-docker-images.yml', - ref: github.ref, - inputs: { - branch_name: branchName - } - }); - console.log(response); + run: gh workflow run build-docker-images.yml --ref ${{ github.head_ref || github.ref_name }} env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 097c543c5e3a8cfac8011bca47d684b4d36d83b3 Mon Sep 17 00:00:00 2001 From: Ajit Padhi Date: Thu, 5 Dec 2024 15:21:13 +0530 Subject: [PATCH 5/8] updated workflow --- .github/workflows/tests.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 042316165..7154bb34e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -102,6 +102,8 @@ jobs: - name: Set GH_TOKEN run: echo "GH_TOKEN=${{ secrets.GITHUB_TOKEN }}" >> $GITHUB_ENV - name: Trigger Build Docker Images Workflow - run: gh workflow run build-docker-images.yml --ref ${{ github.head_ref || github.ref_name }} + run: | + BRANCH_NAME=${GITHUB_REF#refs/heads/} + gh workflow run build-docker-images.yml --ref $BRANCH_NAME -f branch_name=$BRANCH_NAME env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 4b10bbd40966636f84d1d67699f68436a7e7d763 Mon Sep 17 00:00:00 2001 From: Ajit Padhi Date: Thu, 5 Dec 2024 15:24:12 +0530 Subject: [PATCH 6/8] updated workflow --- .github/workflows/tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 7154bb34e..32b7e505f 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -102,6 +102,7 @@ jobs: - name: Set GH_TOKEN run: echo "GH_TOKEN=${{ secrets.GITHUB_TOKEN }}" >> $GITHUB_ENV - name: Trigger Build Docker Images Workflow + if: github.event_name != 'pull_request' run: | BRANCH_NAME=${GITHUB_REF#refs/heads/} gh workflow run build-docker-images.yml --ref $BRANCH_NAME -f branch_name=$BRANCH_NAME From 3db28805fdd474367f29e08aecfbf48f61302cf8 Mon Sep 17 00:00:00 2001 From: Ajit Padhi Date: Thu, 5 Dec 2024 15:48:14 +0530 Subject: [PATCH 7/8] updated workflow --- .github/workflows/build-docker-images.yml | 12 +----------- .github/workflows/tests.yml | 11 ----------- 2 files changed, 1 insertion(+), 22 deletions(-) diff --git a/.github/workflows/build-docker-images.yml b/.github/workflows/build-docker-images.yml index 340ae5496..7a9a85d69 100644 --- a/.github/workflows/build-docker-images.yml +++ b/.github/workflows/build-docker-images.yml @@ -19,11 +19,6 @@ on: - reopened - synchronize merge_group: - workflow_dispatch: # Allow manual triggering - inputs: - branch_name: - description: 'Branch name' - required: true jobs: test-job: @@ -32,14 +27,9 @@ jobs: steps: - uses: actions/checkout@v4 with: - ref: ${{ github.event.inputs.branch_name }} + ref: ${{ github.ref_name }} - run: git branch - run: env - - name: Print Debug Info - run: | - echo "Event Name: ${{ github.event_name }}" - echo "Workflow Conclusion: ${{ github.event.workflow_run.conclusion }}" - echo "Branch Name: ${{ github.event.inputs.branch_name || env.BRANCH_NAME }}" docker-build: if: ${{ github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success' }} diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 32b7e505f..52804657b 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -97,14 +97,3 @@ jobs: run: make unittest-frontend - name: Lint run: make lint - - name: Install GitHub CLI - run: sudo apt-get install gh - - name: Set GH_TOKEN - run: echo "GH_TOKEN=${{ secrets.GITHUB_TOKEN }}" >> $GITHUB_ENV - - name: Trigger Build Docker Images Workflow - if: github.event_name != 'pull_request' - run: | - BRANCH_NAME=${GITHUB_REF#refs/heads/} - gh workflow run build-docker-images.yml --ref $BRANCH_NAME -f branch_name=$BRANCH_NAME - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} From cd2fb806d6f4bf13669831174b64ae70c9294df5 Mon Sep 17 00:00:00 2001 From: Ajit Padhi Date: Thu, 5 Dec 2024 18:46:25 +0530 Subject: [PATCH 8/8] updated workflow --- .github/workflows/build-docker-images.yml | 32 +++-------------------- .github/workflows/build-docker.yml | 11 ++++---- 2 files changed, 9 insertions(+), 34 deletions(-) diff --git a/.github/workflows/build-docker-images.yml b/.github/workflows/build-docker-images.yml index 7a9a85d69..7e9b4a873 100644 --- a/.github/workflows/build-docker-images.yml +++ b/.github/workflows/build-docker-images.yml @@ -1,38 +1,15 @@ name: Build Docker Images on: - workflow_run: - workflows: [Tests] - types: [completed] + push: branches: - main - dev - demo - pull_request: - branches: - - main - - dev - - demo - types: - - opened - - ready_for_review - - reopened - - synchronize merge_group: jobs: - test-job: - name: Test Step - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - ref: ${{ github.ref_name }} - - run: git branch - - run: env - docker-build: - if: ${{ github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success' }} strategy: matrix: include: @@ -44,10 +21,9 @@ jobs: dockerfile: docker/Frontend.Dockerfile uses: ./.github/workflows/build-docker.yml with: - registry: ${{ github.event.workflow_run.head_branch == 'main' && 'fruoccopublic.azurecr.io' || 'cwydcontainerreg.azurecr.io'}} - username: ${{ github.event.workflow_run.head_branch == 'main' && 'fruoccopublic' || 'cwydcontainerreg'}} + registry: ${{ github.ref_name == 'main' && 'fruoccopublic.azurecr.io' || 'cwydcontainerreg.azurecr.io'}} + username: ${{ github.ref_name == 'main' && 'fruoccopublic' || 'cwydcontainerreg'}} app_name: ${{ matrix.app_name }} dockerfile: ${{ matrix.dockerfile }} - branch: ${{ github.event.workflow_run.head_branch }} - push: ${{ github.event_name == 'workflow_run' && (github.event.workflow_run.head_branch == 'main' || github.event.workflow_run.head_branch == 'dev' || github.event.workflow_run.head_branch == 'demo') }} + push: ${{ github.ref_name == 'main' || github.ref_name == 'dev' || github.ref_name == 'demo' }} secrets: inherit diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml index f79cc25f5..f03a9a737 100644 --- a/.github/workflows/build-docker.yml +++ b/.github/workflows/build-docker.yml @@ -15,9 +15,6 @@ on: dockerfile: required: true type: string - branch: - required: true - type: string push: required: true type: boolean @@ -31,10 +28,12 @@ jobs: docker-build: runs-on: ubuntu-latest steps: - - name: Get branch detail + - name: Print branch detail run: | - echo "Input status ${{ inputs.push }}" - echo "Input branch ${{ inputs.branch }}" + echo "${{ inputs.push }}" + echo "${{ github.ref_name }}" + - name: Checkout + uses: actions/checkout@v4 - name: Docker Login if: ${{ inputs.push == true && github.ref_name == 'main' }}