Can action inputs be arrays?

I’m trying set an input to an array of objects:

https://github.com/gr2m/create-or-update-pull-request-action/blob/2e8e0f302be724ab3fd6f8f3ff0a2f299c24507a/.github/workflows/test.yml#L54-L65

It seems like GitHub does not currently support arrays for action inputs? I get this error:

https://github.com/gr2m/create-or-update-pull-request-action/pull/43/checks?check_run_id=246971973

Your workflow file was invalid: The pipeline is not valid. .github/workflows/test.yml (Line: 60, Col: 13): A sequence was not expected

The error message is not very clear, but I assume it means that it expects a simple value, not an array?

4 Likes

Action inputs only supports string keys and string values at this time. This is because they translate to environment variables within the action’s execution run.

Your action can however parse that string value. For example, I parse one of the inputs in my GH Releases action by splitting on newlines https://github.com/softprops/action-gh-release#%EF%B8%8F-uploading-release-assets

-name:Releaseuses:softprops/action-gh-release@v1if:startsWith(github.ref, 'refs/tags/')with:
files:| Release.txt LICENSE

In you’re case you could do potentially something with a bit more structure but that structure needs to be serialized within a yaml string

5 Likes

As another workaround I use JSON as string value for action input.

eg:

steps:
-uses:s4u/maven-settings-action@v1with:
servers:'[{"id": "serverId", "username": "username", "password": "password"}]'
8 Likes

great solution, thanks