Upload only when merging not on merge request

I have a working pipeline but I noticed one thing that might be a bad choice of mine and that is the uploading part. When someone creates a merge request, my script will build the project, execute the tests and then upload everything to the server. I only want this last step (upload to server) to be done when the merge request is “accepted” so to speak. It is a bit strange to upload everything to the server while the merge request has not been accepted yet.

Can anyone tell me how I can do this?

My code below:

stages:
    - build
    - test
    - deploy

build project:
    stage: build
    image: node:11
    only:
        - merge_requests
    script:
        - npm install --progress=false
        - npm run build
    artifacts:
        paths:
            - ./dist

test build:
    stage: test
    image: alpine
    only:
        - merge_requests
    script:
        - cd dist
        - grep -q "<title>MySite</title>" index.html

deploy master:
    stage: deploy
    only:
        - merge_requests
    before_script:
        - 'which ssh-agent || ( apt-get install -qq openssh-client )'
        - eval $(ssh-agent -s)
        - ssh-add <(echo "$SSH_PRIVATE_KEY")
        - mkdir -p ~/.ssh
        - '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'

    script:
        - apt-get update -qq && apt-get install -y -qq lftp
        - lftp -c "set sftp:auto-confirm yes;set ssl:verify-certificate no;  open -u $SFTP_USER,$SFTP_PASSWORD sftp://$SFTP_HOST; mirror --reverse --verbose --delete --exclude api/ dist/ /var/www/mysite.com; bye";

so basically what I want is that the “build stage” only gets executed when the merge request has been accepted, because when it is accepted and we, ourselfs, click on the “merge” button or used the “merge automatically” button, then it should be uploaded.

Hope someone can help me out.