Github Action Workflow with 2 drop down inputs interconnected

I have tried to build a github workflow with below requirement.

I need two inputs from user when they trigger the workflow manually.The first drop down has two options ‘odd’ and ‘even’. second Drop down has four option ‘1’ ‘2’ ‘3’ ‘4’. If I select odd in first dropdown, I should only get 1 or 3 in the second dropdown.

To achieve this, I have created workflow but it is not working and it is throwing error Invalid type found array was expected but string was found.

name: User Input Workflow
on:
  workflow_dispatch:
    inputs:
      dropdown_input_1:
        description: 'Select even or odd'
        required: true
        default: 'even'
        options:
'even'
'odd'
      dropdown_input_2:
        description: 'Select a number'
        required: true
        options: ${{ if(eq(github.event.inputs.dropdown_input_1, 'odd'), '1,3', '2,4') }}
jobs:
  process_inputs:
    runs-on: ubuntu-latest
    steps:
name: Display Inputs
      run: |
        echo "Selected Option 1: ${{ github.event.inputs.dropdown_input_1 }}"
        echo "Selected Option 2: ${{ github.event.inputs.dropdown_input_2 }}"

Leave a Comment