Reusable code advice

what is a best practice for taking a step that is common to several actions and moving it to a single place that each action then references? and specifically, a step that changes the running file system (e.g. installs something)…

i am helping someone refactor a site, and many of the actions start by installing jq as a step. so i thought a good place for me to get my feet wet (i’m new to all this) would be to pull that code out and put it in one place.

first idea was to put it in a reusable workflow, but those seem to run in their own vms, so they don’t affect the calling job’s workspace. next idea was a javascript action, which i think gets inlined (?), but before i head there i thought i’d see if i’m on the right track

another option i thought of was to have a customized runner, but that only solves this one problem - if i start getting a lot of different things i need to do, the runner could get a bit unwieldy, yes?

any advice welcome, thanks!

A custom action is probably the best, yes. If you just want to run a shell command a composite action is likely the simplest solution, otherwise Javascript. A Docker Action is not going to work unless you install to the working directory. :wink:

1 Like