We have a repo with three main branches - dev, staging, production. This is for a legacy style site and I have implemented automation of the build, test and deploy phases. On the dev branch, the pipeline runs on commit just fine and we are happy with this.
The build phase manually pulls the committed changes and runs the build steps.
The test phase deploys the built site to a kubernetes pod that is used for running the tests.
The deploy phase switches the test deployment to the live deployment (if the build and tests succeed).
On staging and production, we are using a merge results pipeline and would like to run the build and test stages when an MR is raised and the deployment stage when the MR passes the tests and is approved.
I noted that the pipeline runs when an MR is raised, but it does not appear to run when the “Merge” button is pressed in the Gitlab UI. I have tried using if conditions to test if the commit is to the target branch, but either my condition is wrong, or the pipeline is not being triggered.
I have read a number of different posts but have not been able to find a suitable guide, which makes me wonder if what we are trying to do is an acceptable practice.
For the time being, I have set the deployment stage to be manual, but ideally I would like to trigger it when the approver clicks the “Merge” button. Is this possible?