1

So, i have tried different versions of this, but i still cannot get it right. I have a github actions pipeline where i would like to insert a choice so people don't have to look for it in documentation:

name: Echo message
on:
  workflow_dispatch:
    inputs:
      hubAddressGroupObject:
        type: choice
        description: 'Enter the name of the hub where the entry is added'
        required: true
        default: 'AZURE-EUW-XXXXX'
        options:
          - 'AZURE-EUW-XXXXX'
          - 'AZURE-FRC-XXXXX'
          - 'AZURE-USE-XXXXX'
          - 'AZURE-FRC-XXXXX'

 jobs:
   build:
     runs-on: ubuntu-latest

     steps:
       - uses: actions/checkout@v2
       - name: WriteMessage
         shell: pwsh
         run: |
           Test-script.ps1 -message "${{ github.event.inputs.hubAddressGroupObject }}"

The 'Test-script.p1' can look like this:

    param (
    [string] $message
)
Write-Host ('{0}' -f $message)

The output is still a normal workflow_dispatch with no choice. What am i doing wrong? Also, i have merged the current branch into main (default).

Alex
  • 75
  • 7
  • Please create a minimal but complete example that somebody could copy to reproduce the scenario. – rethab Jun 10 '22 at 10:29
  • Edited to look like a small example anyone can use. Let me know your thoughts. Thanks. – Alex Jun 10 '22 at 11:23
  • as debugging help, I would suggest to add an intermediate step that pick the value from the event and put in an env variable, so you can understand if the issue is in the script or in how the value is taken from the event itself – Matteo Jun 10 '22 at 12:11
  • The issue is not in the script and the template for 'choice' is correct. My pipeline runs ok, but i would like to improve it by adding the choice. I don't think i made myself clear: when i want to run the pipeline manually, i don't have a drop-down, but just a single field for text. I would like a drop-down to choose values from. For some reason, it doesn't work with the code i posted. – Alex Jun 10 '22 at 14:25

1 Answers1

1

your code seems to be correct, you have space issue's with "jobs",

shift-tab it and it should work:

name: Echo message
on:
  workflow_dispatch:
    inputs:
      hubAddressGroupObject:
        type: choice
        description: 'Enter the name of the hub where the entry is added'
        required: true
        default: 'AZURE-EUW-XXXXX'
        options:
          - 'AZURE-EUW-XXXXX'
          - 'AZURE-FRC-XXXXX'
          - 'AZURE-USE-XXXXX'
          - 'AZURE-FRC-XXXXX'

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: WriteMessage
        run: |
          echo "${{ github.event.inputs.hubAddressGroupObject }}"

enter image description here enter image description here

a.k
  • 1,035
  • 10
  • 27
  • I'm afraid that did not work for me. I shift+tabbed the code, but i have the same result: no choice. – Alex Jun 13 '22 at 12:44
  • where are you running this from? is it from master branch? – a.k Jun 13 '22 at 19:38
  • using a 'develop' branch, but even after a merge, main and develop are the same and the drop down is not there. Using Github Enterprise (private repo) – Alex Jun 14 '22 at 06:21
  • I am accepting your answer as being the best one (not that i have other options) as there is something else going on that i have to figure out. Thanks for the help! I appreciate it! – Alex Jun 15 '22 at 09:03
  • 1
    haha, sorry @Alex – a.k Jun 15 '22 at 14:05
  • I have to add that something has changed and the code below with the indentation that you removed for jobs now works and the choices have appeared. Did Github Enterprise got an update recently? – Alex Jun 21 '22 at 06:49
  • I have no clue, glad to hear all works! @Alex – a.k Jun 21 '22 at 08:36