Re-use previous run #26908
-
Hi, I would like to call a function from a sh script on a different run. Both functions are in the same script (my_script.sh). However, I would like to have a different “step name” on my GitHub action. How can I achieve that? The code below generates an error:
thank you for your feedback |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
Each step gets a fresh Bash instance, so all loaded functions are lost, and you’ll have to source the script file again. Though in my opinion it’d be nicer to handle the function selection with command line options (maybe a subcommand?) instead of sourcing the script and then calling the function. If sourcing/running the script twice creates undesirable side effects that may be the real problem to address. |
Beta Was this translation helpful? Give feedback.
-
Thank you @airtower-luna for your feedback. I will follow your advice and review the design of my script and Github action. |
Beta Was this translation helpful? Give feedback.
-
Oh, one thing I forgot earlier: You can create groups within the output of one step, with the
In the log view this will create a folding structure inside the step. |
Beta Was this translation helpful? Give feedback.
Each step gets a fresh Bash instance, so all loaded functions are lost, and you’ll have to source the script file again. Though in my opinion it’d be nicer to handle the function selection with command line options (maybe a subcommand?) instead of sourcing the script and then calling the function.
If sourcing/running the script twice creates undesirable side effects that may be the real problem to address.