Run steps in workflow in different containers


What is the best solution to run steps in different containers in a workflow? I want to run a build step in a container, and a test step in another one, for example.

I have tried to set two different jobs in the same workflow, but i have realised that the workspace is not shared, so this is a problem as i want to run the test on the artefact i have built.

I can do stash or even use upload-artefact, but i dont know if this is the best way to do it or if there is a specific solution to solve this problem.


Which is the best option depends on the details of your project. There’s no built-in thing to say “run this step in that container”. Alternatives I can think of spontaneously:

  • Manually run containers (e.g. docker run) in steps. With mounts and custom entrypoint you should be able to use the files from the runner.
  • Use custom Docker Actions. Each action gets its own container instance, and the workspace is mounted automatically.