Every developer knows this story. We are working on our amazing project the whole week and we finally finish the project on Friday around 2:00 PM. The only thing that we need to do is just deploy our new website, app or feature and then go celebrate and see happy users.
No, that’s not a recommended way. You should wait with deploy until tomorrow because Friday is a magic day and very often something will start not working after you deploy the site and leave the office. Usually, something means your whole site, not just your new feature.
Solution? “Don’t deploy on Friday” check in your CI/CD pipeline.
Continuous Integration/Continuous Delivery (CI/CD) is a tool that can automate your steps that are necessary for delivering your software to users, customers or clients. You can configure your pipeline that contains steps such us build, test and deploy.
This configuration is usually inside your Git repository. I will use Gitlab CI/CD syntax for the “Don’t deploy on Friday” check but you can implement this check also in CircleCI or any other platform.
It is possible to implement as a single step and your pipeline will fail when you are trying to deploy on Friday.
# .gitlab-ci.yml stages: - good_day_for_deploy - deploy test_is_friday: stage: good_day_for_deploy script: - > if [[ $(date +%u) -ge 5 ]]; then exit 1 fi deploy: stage: deploy script: echo "Your deploy statement..."
This pipeline will not run a deploy job in case that the current day is Friday, Saturday or Sunday.
The previous approach has a small disadvantage. If it’s a Friday, your pipeline will fail and you will get a mail notification. However, I’m not sure about pipeline result meaning because your code can be OK and Friday does not have to mean that this version is incorrect.
The following implementation will check the current day inside deploy pipeline and the pipeline will not fail in case of Friday or weekend.
# .gitlab-ci.yml stages: - deploy deploy: stage: deploy script: - > if [[ $(date +%u) -ge 5 ]]; then echo "It's Friday or weekend! Wait for Monday..." else echo "Your deploy statement..." fi
I hope this article will save you at least one stressful Friday evening or weekend. If you have an idea of how to improve this pipeline feel free to share the idea in comments. Also, you can follow me on your favorite social site for other articles, tips, and inspiration or you can subscribe to my newsletter.
Good luck with deploys on Friday!