Querying stack state before sls deploy to avoid failures due to UPDATE_IN_PROGRESS

Hey there,
We’re using serverless for our CI process, and a common issue we have is that if we push 2 commits to close to each other, the second one fails due to:

Stack:arn:aws:cloudformation:**** is in UPDATE_IN_PROGRESS state and can not be updated.

This is especially bad because it can happen if two people merged into a master right after another.

The workaround we do is to wait a little and then rerun the CI manually.
What I’d like is for sls deploy not to happen until the stack is ready to be overwritten. This seems like something that should be bundled.
Is there an easy way to do it?
Alternatively, is there a way to poll the stack state programmatically so I can wait before calling sls deploy?

If you’ve got the AWS CLI in CI, you should be able to use it to wait on the stack to transition to another state like this:

aws cloudformation wait stack-update-complete --stack-name="YOUR_STACK_NAME"