Failed Github Pages deploys to gh-pages

For some reason, my build deploys to gh-pages from the master branch even though the code is messed up… I thought that the failed builds are not suppose to deploy.

unknown

language: node_js
node_js:
  - "stable"
cache:
  directories:
  - node_modules
script:
  - npm run build
deploy:
  provider: pages
  skip_cleanup: true
  github_token: $github_token
  local_dir: build
  on:
branch: master
    {
     "name": "portfolio-website",
     "version": "1.0.2",
     "description": "",
     "main": "index.html",
     "scripts": {
            "build": "",
            "deploy": "gh-pages -d build"
     },
     "author": "",
     "license": ""
    }

When reporting a problem, please include relevant build URLs. Thanks.