Run action after merging MR to master/main Git branch

I’m new to Gitlab and I’m trying to set up CI/CD pipeline in order to make an additional action after merging MR to main Git branch.
For instance, when merge request is merged run a NPM command, like npm run download-translations, so developers won’t have to include translations into MR avoiding merge conflicts.

There are 2 questions:

  • how to set up such an action?
  • is it possible to run NPM command when running such action?

Thanks for understanding and help in advance. Any suggestions or links to docs explaining my use case would be very helpful.

You can setup a job and specify rules to run the job only on master branch.

npm download translations:
  ... other stuff ...
  rules:
    - if: $CI_COMMIT_BRANCH == "master" && $CI_PIPELINE_SOURCE == "push"
      when: always
    - when: never
  script:
    - npm run download-translations

Thank you :slight_smile: