Can Docker action receive a list as an input argument? #26938
-
When creating my own Docker action, I can pass arguments to it using
In my action’s entrypoint.sh script I can then reference the Is it possible to have a key that will have a value that is an array, like:
If that is possible, how would I reference that in my entrypoint.sh? Are those inputs passed as env variables inside the script that I could then reference with names instead of numbers, like The aim is to reference that key with array value so that I can loop through it in my bash script. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Hi @dingo-d , The input variable type only supports string , number and boolean. So an input key with array value is not supported. You could consider to convert the string into array in entrypoint.sh . >>Are those inputs passed as env variables inside the script that I could then reference with names instead of numbers, like There are env variables for inputs when using the docker container action. But the env name has an INPUT_ prefix and all the letters are in uppercase. Please note that ‘-’ is an invalid charture in shell variable name, you could use ‘_’ instead. I change all the input variables to use ‘_’ . Such as ‘wp_db_name’ . You could use $INPUT_WP_DB_USER in your entrypoint.sh. There is the action setting in workflow yml:
And entrypoint.sh example:
|
Beta Was this translation helpful? Give feedback.
-
Thank you for the explanation! I’ll see about using string and converting it to array in the entrypoint, that’s a useful tip, as well as with the inputs :) |
Beta Was this translation helpful? Give feedback.
Hi @dingo-d ,
The input variable type only supports string , number and boolean. So an input key with array value is not supported. You could consider to convert the string into array in entrypoint.sh .
>>Are those inputs passed as env variables inside the script that I could then reference with names instead of numbers, like
$wp-db-name
etc.?There are env variables for inputs when using the docker container action. But the env name has an INPUT_ prefix and all the letters are in uppercase. Please note that ‘-’ is an invalid charture in shell variable name, you could use ‘_’ instead. I change all the input variables to use ‘_’ . Such as ‘wp_db_name’ .