CI how to control when the stage will be triggered?

Hello,
I have this configuration:

#########################################
#CI/CD file
image: node:latest

cache:
paths:
- node_modules/

stages:

  • test
  • deploy

check_for_err:
stage: test
before_script:
- npm install
script:
- npm run eslint-build
- npm run eslint
artifacts:
paths:
- node_modules/
only:
- branches
- pushes

pages:
stage: deploy
before_script:

  • npm install
    script:
  • npm run build
  • gzip -k -9 -r public
    artifacts:
    paths:
    • public
      only:
  • master@ycbarrosocu/travel-book
    except:
    - branches

#######################################################
I want to deploy to gitlab-pages only when the Merge Request to master is accepted.
How I need to configure my CI file?
thanks in advance.