name: Node CI

on: [push, pull_request]

jobs:

  tests:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        node-version: [10, 12, 13]
    steps:
    - uses: actions/checkout@v1
    - name: Use Node.js ${{ matrix.node-version }}
      uses: actions/setup-node@v1
      with:
        node-version: ${{ matrix.node-version }}
    - name: install dependencies
      run: |
        npm ci
    - name: run tests
      run: |
        npm test     
    - name: Coveralls
      if: matrix.node-version == 12
      uses: coverallsapp/github-action@master
      with:
        github-token: ${{ secrets.github_token }}
    - name: Generate Docs
      run: |
        npm run generate-docs

  deploy:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        node-version: [12]
    needs: tests
    if: github.ref == 'refs/heads/master'
    steps:
    - uses: actions/checkout@v1
    - name: install dependencies
      run: |
        npm ci
    - name: Generate Docs
      run: |
        npm run generate-docs
    - name: Deploy on Github Pages
      uses: JamesIves/github-pages-deploy-action@master
      env:
        ACCESS_TOKEN: ${{secrets.ACCESS_TOKEN}}
        BASE_BRANCH: master
        BRANCH: gh-pages
        FOLDER: typedoc