A minor comment - In theory, this code will try to undeploy even if the deploy failed.