Only tag in build file

I have a question about the build file. How can I make sure only tags on the master branch are deployed to production and not commits?! You can find my deployment section for our production branch below:

deployProduction:
    script:
        - grunt build:production  --no-test
        - grunt deploy_only:production
    stage: deploy
    only:
        - tags
        - master