name: Node.js CI

on:
  push:
    branches:
      - master
  pull_request:

jobs:
  test-build-release:

    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2
      - name: Use Node.js 12.x
        uses: actions/setup-node@v1
        with:
          node-version: 12.x
      - name: Install npm packages using cache
        uses: bahmutov/npm-install@v1

      # Install AWS CLI for uploading storybook to S3
      #- name: Install PyEnv Global
      #  run: pyenv global 3.7.1 ##
      #- name: Install pip
      #  run: pip install -U pip
      #- name: Install AWS CLI
      #  run: pip install awscli

      - name: Lint code
        run: yarn lint
      - name: Run tests with coverage
        run: yarn cover

      # at this point, the build is successful
      - name: Codecov
        uses: codecov/codecov-action@v1.2.0
        continue-on-error: true
      - name: Semantic Release
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
        run: semantic-release

      # Deploy storybook demo to S3 if handling a non-PR build on the main branch
      # https://s3.amazonaws.com/transitive.js/index.html
      #- name: Deploy storybook to S3
      #  run: if [ "$TRAVIS_BRANCH" = "master" -a "$TRAVIS_PULL_REQUEST" = "false" ]; then yarn deploy-storybook; else echo 'skipping deploy to s3'; fi

Add CI workflow (without AWS at this time)
ci(CI): Add CI workflow (without AWS at this time)
