How to run actions by Pipelines, not by jobs

Hey, everyone!

I am hosting my own runner for Github Actions. And I have one problem: I need to make actions run by pipelines, not by jobs.

Suppose, I have a testing.yml that has two jobs: testing and cleanup-containers that depend on testing. And the actions will trigger on the pull request.

If two people create pull request jobs will run in the following order: testing 1, testing 2, cleanup-containers 1, cleanup-containers 2.

I need to make actions run in this order: testing 1, cleanup-containers 1, testing 2, cleanup-containers 2.

If you have any suggestions, please, let me know.

If steps need to run on the same runner and without anything in between put them into the same job. Each job is supposed to run completely separate from any other (other than needs relationships and artifact transfer, if any).

From the job names I guess that the “cleanup-containers” job is supposed to delete containers created by the “testing” job. Just move the cleanup to the end of the testing job (basically make it clean up after itself). You might want to use if: always() or something similar so the cleanup runs even if the tests failed.

1 Like

If you’re using self-hosted runners, you could use a job to define a matrix that picks the self-hosted runner for all of the remaining jobs.

The rest of it could be accomplished with a lot of needs:.

1 Like