You can already do this through version control, including on premise GitLab. You can use the GitLab Deployments extension for it. I’m sure it’s also possible to do it directly through the Management API, but can’t quickly find any helpful docs for you on that. The GitLab extension should cover your use case, though.