The problem
I'm currently in the process of setting up Travis to run our tests and deploy if the tests are successfull. Which is pretty straight forward, but I don't want to deploy when these conditions are met:
- The time is between 07:00 and 22:00 (workdays)
- During the deploy the database has to migrate or elastic search has to index
Since a migration or an index can be quite expensive and means downtime. I'm using the heroku provider and using the on
parameter is simple enough, however I'm struggling with the following situation:
- Git push triggers new build
- Travis correctly identifies that a deploy is not allowed
- Deploy is skipped using the heroku provider `on` parameter
- Build finishes
5 mins later
- Git push triggers new build
- Travis incorrectly identifies a deploy is allowed (this build doesn't need a migration/index but the previous build did)
- Travis tries to deploy and production breaks
Wanted situation
So what I actually want is something like scheduled/delayed deployments. When Travis detects one of the expensive operations need to run it schedules a deployment and all subsequent builds skip deployment untill the deployment with the expensive scripts is done. That deploy should start automatically anywhere outside business hours.
I hope I've described it clearly, if any more information is needed please let me know!