# This references the default nodejs container from
# the Docker Hub: https://registry.hub.docker.com/_/node/
# If you want Nodesource's container you would reference nodesource/node
# Read more about containers on our dev center
# http://devcenter.wercker.com/docs/containers/index.html
box: node
# This is the build pipeline. Pipelines are the core of wercker
# Read more about pipelines on our dev center
# http://devcenter.wercker.com/docs/pipelines/index.html

# You can also use services such as databases. Read more on our dev center:
# http://devcenter.wercker.com/docs/services/index.html
# services:
    # - postgres
    # http://devcenter.wercker.com/docs/services/postgresql.html

    # - mongo
    # http://devcenter.wercker.com/docs/services/mongodb.html

no-response-timeout: 20
build:
  # The steps that will be executed on build
  # Steps make up the actions in your pipeline
  # Read more about steps on our dev center:
  # http://devcenter.wercker.com/docs/steps/index.html
  steps:
    # A step that executes `npm install` command
    - npm-install
    # A step that executes `npm test` command
#    - npm-test

    # A custom script step, name value is used in the UI
    # and the code value contains the command that get executed
    - script:
        name: echo nodejs information
        code: |
          echo "node version $(node -v) running"
          echo "npm version $(npm -v) running"
    - script:
        name: build gh-pages
        code: npm run docs:build
  after-steps:
    - slack-notifier:
        url: $SLACK_WEBHOOK_URL
        username: wercker
deploy :
  steps :
    - script:
        name: Configure git
        code: |-
          git config --global user.email "javierlecuona@gmail.com"
          git config --global user.name "wercker"

          # remove current .git folder
          rm -rf .git
    - script:
        name: Deploy to github pages
        code: |-
          cd dist
          git init
          git add .
          git commit -m "deploy commit from $WERCKER_STARTED_BY"
          git push -f $GIT_REMOTE HEAD:gh-pages
  after-steps:
    - slack-notifier:
        url: $SLACK_WEBHOOK_URL
        username: wercker
