Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support list input type #184

Open
bryanmacfarlane opened this issue Oct 10, 2019 · 6 comments 路 May be fixed by #1183
Open

Support list input type #184

bryanmacfarlane opened this issue Oct 10, 2019 · 6 comments 路 May be fixed by #1183
Labels
core enhancement New feature or request

Comments

@bryanmacfarlane
Copy link
Member

Thank you 馃檱鈥嶁檧 for wanting to create an issue in this repository. Before you do, please ensure you are filing the issue in the right place. Issues should only be opened on if the issue relates to code in this repository.

If your issue is relevant to this repository, please include the information below:

Describe the enhancement
An action should be able to have an input type which is a list of strings. The toolkit should provide a getInput overload or new method to retrieve it.

Code Snippet

let vals: string[] = core.getListInput('inputName');

Additional information
Add any other context about the feature here.

@kiprasmel
Copy link
Contributor

I was going through https://github.com/actions/cache trying to implement multiple path support, and when going through source code, I only noticed the core.getInput function, but not one for core.getInputs to get multiple of them.

Then, later, I found this:

const restoreKeys = core
	.getInput(Inputs.RestoreKeys)
	.split("\n")
	.filter(x => x !== "");

so, is

let vals: string[] = core.getInput('inputName').split("\n").filter(x => x !== "");

the official way of doing it?

If so, I've created a PR to implement this: #336

@AB-xdev
Copy link

AB-xdev commented Aug 31, 2021

Was this fixed with #829?

@asbjornu
Copy link

@AB-xdev, as far as I can tell, #829 implements support for values spanning multiple lines, not lists. With the implemented core.getMultilineInput() the following should be possible:

- uses: myaction
  with:
    multiline-param: |
      line1
      line2
      line3

However, the following is still not possible:

- uses: myaction
  with:
    list-param: ['item1', 'item2', 'item3']

Neither is this:

- uses: myaction
  with:
    list-param:
      - item1
      - item2
      - item3

@rickstaa
Copy link

@asbjornu Good extension! I created #1183 to also implement the second case. Not sure how to implement the last case since these parameters are passed as an environment parameter.

@git-developer
Copy link

I'm happy with this workaround posted on StackOverflow:

  1. Definition: Use a property of type string and a literal with the JSON representation of the list, e.g. products: '["yellow", "green"]'
  2. Use: Decode the string literal to a JSON list, e.g. ${{ fromJSON(inputs.products) }}

Example:

on:
  workflow_dispatch:
    inputs:
      products:
        description: "List of Products"
        default: '["yellow"]'
      limits:
        description: "List of limits"
        default: '[50]'

jobs:
  build:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        product: ${{ fromJSON(github.event.inputs.products) }}
        limits: ${{ fromJSON(github.event.inputs.limits) }}

@Edwardius
Copy link

can we have this pwease :3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core enhancement New feature or request
Projects
None yet
8 participants