Default Input is empty when Github Action crop is execute

Viewed 29

I am trying to get default value when github action execute by cron job. but it picking empty instead of default value.

Note getting why its not picking default value. Any idea?

Here is my code

workflow_dispatch:
    inputs:
      typeOfTesting:
        type: choice
        description: Select Type of Test
        default: "stage-test"
        required: true
        options:
          - stage-test-local-All
          - stage-test
          - stage-test-Uptime

  schedule:
    - cron: "0 1 * * *"
    - cron: "0 11 * * *"

jobs:
  WebdriverIO-Automation:
    runs-on: ubuntu-latest
    steps:
      - name: Selection of Testing type
        run: |
          echo "Branch Name: ${{ github.event.inputs.typeOfTesting }}"

Output:

enter image description here

1 Answers

inputs is not available to cron triggers. They are available to workflows triggered by the workflow_dispatch event only.

If you want to default value for corn you need to handle it in a step like:

workflow_dispatch:
    inputs:
      typeOfTesting:
        type: choice
        description: Select Type of Test
        default: "stage-test"
        required: true
        options:
          - stage-test-local-All
          - stage-test
          - stage-test-Uptime

  schedule:
    - cron: "0 1 * * *"
    - cron: "0 11 * * *"

jobs:
  WebdriverIO-Automation:
    runs-on: ubuntu-latest
    steps:
      - name: Selection of Testing type
        run: |
          echo "Branch Name: ${{ github.event.inputs.typeOfTesting == '' && github.event.inputs.typeOfTesting  || 'stage-test' }}"

Please take look here for a fake ternary expression:

steps:
      - name: stuff
        env:
          PR_NUMBER_OR_MASTER: ${{ github.event.number == 0 && 'master' ||  format('pr-{0}', github.event.number)  }}
Related