Search code examples
github-actions-workflows

How to call either one reusable workflow from caller workflow by using workflow_dispatch and passing parameter with filename


I have created two reusable workflow in abc repo javaci.yml databaseci.yml

I can trigger reusable workflow from caller workflow simultaneously but I need to choose any one or both yml file to trigger by using parameter

below are the my caller workflow

name: caller workflow

on: workflow_dispatch:

jobs:

trigger_javaci: 
   uses: abc/github-actions-shared-workflow/.github/workflows/javaci.yml@main
   
   secrets:
     Workflow2_PAT_TOKEN_GITHUB: ${{ secrets.Workflow2_PAT_TOKEN_GITHUB }}

trigger_databaseci: 
   uses: abc/github-actions-shared-workflow/.github/workflows/databaseci.yml@main


   secrets:
     Workflow2_PAT_TOKEN_GITHUB: ${{ secrets.Workflow2_PAT_TOKEN_GITHUB }}

While running Caller workflow, am getting both reusable workflow, but i want particularly any one called workflow to trigger by using parameter values.

So kindly help on this...

Thank you


Solution

  • Finally I found the solution to call either one or both reusable workflow from caller workflow

    name: multiple-reusable-caller workflow
    
    on:
     workflow_dispatch:
       inputs: 
         javaci: 
            type: boolean
            description: 'deploy javaci'
            required: true
         databaseci: 
            type: boolean
            description: 'deploy databaseci'
            required: true        
     
    jobs:
    
        deploy_javaci: 
           if: ${{github.event.inputs.javaci == 'true'}}
           uses: abc/reusable-workflow-ci/.github/workflows/javaci.yml@main
           
           secrets:
             Workflow2_PAT_TOKEN_GITHUB: ${{ secrets.Workflow2_PAT_TOKEN_GITHUB }}
    
        deploy_databaseci: 
           if: ${{github.event.inputs.databaseci == 'true'}}
           uses: abc/reusable-workflow-ci/.github/workflows/databaseci.yml@main
           
           secrets:
             Workflow2_PAT_TOKEN_GITHUB: ${{ secrets.Workflow2_PAT_TOKEN_GITHUB }}