Expression for array concatenation #11401
|
Currently documentation features expressions for checking if array contains a value or joining an array into a string, but there's no way to merge two arrays or append a value to an array. A possible use case is adding more runner labels for reusable workflows, i.e.: This is currently possible with some sort of configuration job dependency, but would be nice if one could do it instantly. |
Replies: 4 comments 2 replies
|
Thanks @alexbatashev - I appreciate the feedback. This is on our backlog but I don't know when we'll work on it. |
|
You can work around this using (Obviously it'd be nicer to have native primitives and not require an extra job.) |
|
Hi @jsoref I just googled: github actions concatenate array, and this was the top post, which turns out to exactly matched the use case I had in mind. "adding more runner labels". I would like to add labels to |
|
Doing this in pure actions yaml, without a job doing the work is pretty easy if you know the syntax runs-on:
- x64
- build
- ${{ inputs.os }} # assumes `inputs.os` is a stringruns-on: [x64, build, "${{ inputs.os }}"] # assumes `inputs.os` is a string, quotes are required due to json like notation and `{`/`}` brackets.Now some examples using json in runs-on:
- x64
- build
- ${{ fromjson(inputs.os) }} # assumes `inputs.os` is a json string literal or a json array (if it is an array the list of labels is appended by the json lst)runs-on: [x64, build, "${{ fromjson(inputs.os) }}"] # assumes `inputs.os` is a json string literal or a json array (if it is an array the list of labels is appended by the json lst), quotes are required due to json like notation and `{`/`}` brackets. |
Thanks @alexbatashev - I appreciate the feedback. This is on our backlog but I don't know when we'll work on it.