githubcontinuous-deploymentgithub-actionsbuilding-github-actions

Trouble trying to run queued Github Actions


I got a case where two GitHub Actions are running concurrently (as intended) with a push on master branch. Problem is, I want it to run in a queue instead and I couldn't find any helpful doc about it. In my case, I needed the action to only run after a run of the same action ends as my deploy breaks if its still executing the last one. I would have to deal with a third-party cli that I didn't want to in first place to make it wait instead of straight up deploying, I would very much prefer doing it on the whole action.


Solution

  • I see here the following solutions:

    1. You can "sleep" your dependant workflow to simulate a waiting for 1st workflow. wait-action might help you with that.
    2. You can try to trigger second action from the first action (instead of trigger it on push).

    But all these options tbh are more like hacks. GitHub Actions are designed to run in parallel and if you want to run actions in specific order you should consider to use jobs instead and use needs property to make a dependency between them. Example:

    jobs:
      job1:
        name: Run 1st job
      job2:
        name: Run 2nd job
        needs: job1
    

    Documentation - needs