Should testing and deploying be in the same workflow?

Hey everyone, somewhat new to actions over here. So what I was thinking about setting up is the following:

1 Workflow for running testing on Pull Request
1 Workflow for running testing (again) and deploying (depending on testing) on Push

I would assume we should have 2 different workflows for these, or should we combine everything into one? Essentially I want to set up a testing workflow and a test and deploy workflow

Are there any examples someone can give me of a robust workflow that incorporates all of this?

It depends on what you want. If the testing job is exactly the same, I’d lean towards sharing the code by having one workflow, and just skipping the deploy job if the workflow has been triggered by a pull_request event (see jobs.<job_id>.if).

And I guess you don’t want to deploy from all branches, so the push trigger probably needs a branch filter.

1 Like

Agree with @airtower-luna - I’d also recommend using one workflow. It’s simpler and easier to manage and maintain over time.

It is also currently not easily possible to create dependencies between the two workflows, such as to say once my testing workflow finished successfully, then trigger my publishing workflow. So, until there’s more improvement towards that end, I’d stick to one workflow file.

1 Like