OneDev is a self-hosted DevOps platform with issue tracking, git repository management and built-in CI/CD capabilities. In the latest 4.2.1 version, it is possible to set up pull request to launch live preview of your application and tear it down after pull request is closed.
For demonstration purpose, I set up a Heroku starter application in OneDev, when a pull request is created, the application will be deployed to Heroku, and a link of the deployment will be displayed for reviewers to check like below:
When there are new commits made into the pull request, the application will be re-deployed to reflect current change. After pull request is merged or discarded, the deployment will be removed from Heroku to save resource.
Now let’s check how to achieve this:
Check build job Set Up Live Preview, the Commands deploys current commit of the application to Heroku. The job is set to run automatically when pull request is opened or updated via job Triggers. And in Artifacts & Reports section, the markdown file containing deployed application link will be published as a pull request report
Check build job Tear Down Live Preview, the Commands deletes the deployed application if it exists. The job is set to run automatically when pull request is merged or discarded via job Triggers
Navigate into menu Setting/Build Setting/Job Secrets of the project, define job secret named heroku_email to hold Heroku account email, and heroku_api_key to hold Heroku api key
That is it. Thanks for reading!
This tutorial contains image designed by freepik