Can a workflow be aware of other instances of that workflow

workflow
workflows

#1

I have a workflow with 3 jobs – basically a build, test, and deploy job.

For reasons that would be quite long to explain, the build job generates a unique version number that is the next version number in the deploy sequence. And the deploy job uses that version number to deploy successfully.

But if two builds kick off at about the same time, for example when someone pushes two commits at once, then both commits start to run in parallel and both the build job steps generate the same unique version number. This in turn causes whichever deploy step runs later to fail because a non-unique build number was used.

So my question is – is there any way that I can have a given workflow be aware of other worflows running that are of its same type – so that I could perhaps pause the second workflow from running temporarily or do something else.


#2

I reckon so, but the vague idea in my head is not fully fleshed out. I think this would work for your first job at least: could you use the cache system with the unique version number as the cache key? If you have two triggered workflows that are set to create a race condition, one of them will write the cache key first, and the other one will read the cache value and can avoid doing the build. I am not sure how the test/deploy jobs should work though - maybe you can use the workspaces feature to communicate yes/no from the first job in the workflow?

The other idea that occurs to me is to set the workflow to only trigger on a specific branch, and then restrict merge access to that branch, letting the team know that merging to that branch needs to be done in a coordinated fashion.


#3

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.