name: Deploy NPM

on:
  push:
    branches:
      - master

jobs:
  deploy:
    runs-on: self-hosted
    name: Build and Deploy
    strategy:
      matrix:
        node-version: [12.x]
    steps:
      - uses: actions/checkout@master
        with:
          fetch-depth: 1
      - name: Use Node.js ${{ matrix.node-version }}
        uses: actions/setup-node@master
        with:
          node-version: ${{ matrix.node-version }}
      - name: Install yarn
        run: yarn
      - name: QA check
        run: yarn checkCI
      - name: Build
        run: yarn build
      - name: Deploy
        if: github.ref == 'refs/heads/master'
        env:
          NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
        run: |
          echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
          npm publish
