name: CI

env:
  NODE_OPTIONS: --max-old-space-size=6144

on: [push]

jobs:
  build:
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        node-version: [14.x, 16.x, 18.x]
        os: [ubuntu-latest, windows-latest]
      fail-fast: false
    steps:
      - uses: actions/checkout@v3
        with:
          fetch-depth: 0
      - name: Set branch name
        run: echo >>$GITHUB_ENV BRANCH_NAME=${GITHUB_REF#refs/heads/}
      - name: Echo branch name
        run: echo ${BRANCH_NAME}
      - name: Use Node.js ${{ matrix.node-version }}
        uses: actions/setup-node@v3
        with:
          node-version: ${{ matrix.node-version }}
          registry-url: https://registry.npmjs.org/
      - name: Cache .pnpm-store
        id: cache
        uses: actions/cache@v1
        with:
          path: ~/.pnpm-store
          key: ${{ runner.os }}-node${{ matrix.node-version }}-${{ hashFiles('**/pnpm-lock.yaml') }}
      - name: Install pnpm
        run: npm i pnpm -g
      - run: npm run setup
      - run: npm run dependency:check
      - run: npm run lint
      - run: npm run test
        env:
          TEST: true
      - run: npm run version:check
        env:
          ACCESS_KEY_ID: ${{ secrets.ACCESS_KEY_ID }}
          ACCESS_KEY_SECRET: ${{ secrets.ACCESS_KEY_SECRET }}
          CI: true
