Simplify `.gitlab-ci.yml` syntax for stopping review apps
To declare how to stop a review app, we currently need something like:
review: environment: name: review/$app on_stop: stop_review stop_review: script: echo Delete My App when: manual environment: name: review/$app action: stop
action: stop are redundant; we should be able to get rid of one of them. At one point, we thought we'd only have the
on_stop part as a forward reference to which job stops the environment, but now that we have
action: stop it seems like that is actually more of a consistent way to declare what the job does. i.e. declare what the job does in the job definition itself.
review: environment: name: review/$app stop_review: script: echo Delete My App when: manual environment: name: review/$app action: stop
This opens up the possibly to expand
action. We can say that the default action is
update, and that's used to create or update a review app, but maybe we can differentiate between
update? Our templates currently have all this logic to create the app if necessary on every update, but no only is it a waste of compute, it might not even be the best way to do it. For example, if you deploy to Openshift by creating an app and pushing a Docker image to it, updating the app later should just be a matter of telling it to pull the latest image. Or in fact, it should pull it automatically if it can detect the update, and so updating a review app should just be a matter of tagging a new Docker image. That's very different than what's needed for creation the first time.
An alternate propsal might involve modying the
when condition instead. Perhaps with:
stop_review: script: echo Delete My App when: - manual - branch_delete environment: name: review/$app
This has an advantage of being explicit about running on branch deletion, and means you could even drop the
manual part so it doesn't show up in the interface as an action, if you didn't want it. But then it loses the special nature of
stop, which adds the stop icon in the web UI rather than the play icon.