name: CI

on:
  push:
    branches:
      - master
  pull_request:
    branches:
      - "**"

env:
  CI: true

jobs:
  run:
    runs-on: ${{ matrix.os }}

    strategy:
      fail-fast: false
      matrix:
        node:
          - "10.x"
          - "12.x"
          - "14.x"
        os:
          - "ubuntu-latest"
          - "macos-latest"
          - "windows-latest"

    steps:
      - name: Clone repository
        uses: actions/checkout@v2

      - name: Use Node.js ${{ matrix.node }}
        uses: actions/setup-node@v1
        with:
          node-version: ${{ matrix.node }}

      - name: Install npm dependencies
        run: npm ci

      - name: Build files
        run: npm run compile

      - name: Run bundlewatch
        run: npm run bundlewatch
        if: startsWith(matrix.os, 'ubuntu') && startsWith(matrix.node, '12')
        env:
          BUNDLEWATCH_GITHUB_TOKEN: "${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }}"
