Build: optimized the deploy logic
Merge pull request #6267 from LaurentGoderre/deploy-logic

Build: optimized the deploy logic