name: Node CI

on: [push]

jobs:
  build:
    runs-on: ubuntu-latest

    strategy:
      matrix:
        node-version: [10.x, 12.x]

    steps:
    - uses: actions/checkout@v1
    - name: Use Node.js ${{ matrix.node-version }}
      uses: actions/setup-node@v1
      with:
        node-version: ${{ matrix.node-version }}
    - name: npm install, build, and lint
      run: |
        yarn
        yarn build
        yarn lint
  release:
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v1
    - name: Skip CI
      uses: veggiemonk/skip-commit@master
      env:
        COMMIT_FILTER: skip ci
    - name: Prepare repository
      env:
        GH_TOKEN: ${{ secrets.GH_TOKEN }}
      run: |
        git checkout "${GITHUB_REF:11}"
        git remote rm origin
        git remote add origin "https://$GH_TOKEN@github.com/hipstersmoothie/jest-github-reporter.git"
        git fetch origin
        git branch --set-upstream-to origin/master
    - name: Use Node.js 12.x
      uses: actions/setup-node@v1
      with:
        node-version: 12.x
    - name: Create Release
      env:
        GH_TOKEN: ${{ secrets.GH_TOKEN }}
        NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
      run: |
        git remote -v
        yarn
        yarn build
        yarn release
