52

I've made a new project on GitHub with two workflows:

  • One to test the project
  • And another to publish the resulting Docker image

I'd like the second workflow to trigger only if the first one succeeds. Is there a way to do that? Or would I need to create a single workflow file where the second job depends on the first?

theory
  • 9,178
  • 10
  • 59
  • 129
  • 2
    Maybe this would help - [Dependency between Workflows on GitHub Actions](https://stackoverflow.com/questions/58457140/dependencies-between-workflows-on-github-actions) – riyaz-ali Jun 14 '20 at 06:41
  • Thanks for the links. Thinking about this instead of sleeping last night, I concluded that the point of separate files is best mapped to different triggers (on push vs on release, for example), and that it would be best to have one workflow file for the cases here, with one job testing and a second job publishing, but only after the first finishes successfully, as in the last example in [this answer](https://stackoverflow.com/a/61832535/79202). – theory Jun 14 '20 at 14:01
  • 5
    And [here's how I put the two jobs in one file](https://github.com/pgxn/docker-pgxn-tools/blob/main/.github/workflows/cicd.yml) such that the publish happens only when the test succeeds and it's not a pull request. – theory Jun 14 '20 at 20:59

0 Answers0