Anyone done any work with feature branch based test environments? Seems easy enough to create them based on branch/pr but trying to find a convincing method to shut down those envs when the pr is closed / branch is merged.
Using drone for my ci platform but it doesn't seem to be tracking the right events for this - not sure many do?
Am i on the right track or is there a better logic for wrapping these up? :/
bradymalmost 6 years ago
I've done this a couple ways:
1. cron job that compares git branches to test envs, and shuts down any test envs for branches that have been deleted. This does, of course, rely on branches being deleted after they're merged. I know both github and gitlab now have an option you can set that will auto delete a branch after it is merged to master (or whatever you designate the "main" branch)
2. Gitlab CI has the concept of environments that are tied to branches. When a branch is deleted gitlab will run any jobs you've configured to run at the shutdown of an environment.
I've not used drone, but I'd be surprised if it doesn't have something like events or webhooks that you could use for this.