# This is a basic workflow to help you get started with Actions
name: "CI"

# Controls when the action will run.
on:
  # Triggers the workflow on push or pull request events but only for the master branch
  push:
    branches: ["**"]

  workflow_dispatch:

jobs:
  build:
    name: "Build"
    runs-on: ubuntu-latest
    steps:
      - name: Checkout project
        uses: actions/checkout@v2

      - name: Setup Node
        uses: actions/setup-node@v2
        with:
          node-version: "14.16"
          cache: "yarn"
          cache-dependency-path: "yarn.lock"

      - name: Install
        run: yarn --immutable

      - name: Prettier
        run: yarn prettier:check

      - name: Build
        run: yarn build

      - name: Lint
        run: yarn lint

      - name: Test
        run: yarn test

      - name: Publish
        uses: JS-DevTools/npm-publish@v1
        if: github.ref == 'refs/heads/main'
        with:
          token: ${{ secrets.NPM_TOKEN }}
