Need help with handling protect variable and merge request pipeline

Context: Whenever a user creates a merge request I want to run a CI/CD pipeline which prints out something. The code uses some CI/CD variables. If there are any commits inside this merge request then also pipelines should run doing same thing as when merge request was created. Also when merge request is merged I need to again run a pipeline which will run some different code. Now what I want to know is if someone uses a protect variable then when merge request is created the merge request pipeline can’t access it. So how should we solve this problem? Is there any alternative way to get access to protect variables? Inside this merge request pipeline? Or any other alternative way to solve this problem?