name: Build
on:
  push:
    branches:
      - master
    tags:
      - "v*.*.*"
  pull_request:
    branches:
      - master
  schedule:
    - cron: "0 8 * * 1"

jobs:
  Build:
    runs-on: 'ubuntu-latest'
    container: 'node:${{ matrix.node-version }}'
    strategy:
      matrix:
        node-version:
          - "16"
          - "14"

    steps:
      - uses: actions/checkout@v2
      - run: yarn

  # Publish:
  #   runs-on: 'ubuntu-latest'
  #   needs: Build
  #   if: startsWith(github.ref, 'v')
    
  #   steps:
  #     - uses: actions/checkout@v3
  #     - uses: actions/setup-node@v3
  #       with:
  #         node-version: '16.x'
  #         registry-url: 'https://registry.npmjs.org'
  #     - run: yarn
  #     - run: yarn publish
  #       env:
  #         NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}      

  Documentation:
    runs-on: 'ubuntu-latest'
    needs: Build
    if: github.ref == 'refs/heads/master'
    env:
      DOC_GITHUB_TOKEN: '${{ secrets.DOC_TOKEN }}'
    steps:
      - uses: actions/checkout@v2
      - run: curl https://opensource.byjg.com/add-doc.sh | bash /dev/stdin js yaj-sse