bencevans/node-sonos

View on GitHub
.github/workflows/run-tests.yml

Summary

Maintainability
Test Coverage
name: Run tests
 
on:
  push:
    branches:
      - master
      - beta
      - alpha
  pull_request:

jobs:
  build-and-test:
    runs-on: ubuntu-latest
    steps:
    - name: Checkout
      uses: actions/checkout@v1
    - name: Use node 12
      uses: actions/setup-node@v1
      with:
        node-version: 12
    - name: Install depencencies
      run: npm ci
    - name: Run tests
      run: npm run test
  
  release:
    needs: build-and-test
    runs-on: ubuntu-latest
    if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' || github.ref == 'refs/heads/beta' || github.ref == 'refs/heads/alpha'
    steps:
      - name: Checkout
        uses: actions/checkout@v1
      - name: Use node 12
        uses: actions/setup-node@v1
        with:
          node-version: 12
      - uses: svrooij/secret-gate-action@v1 # see https://github.com/svrooij/secret-gate-action this is to fail quiet until secret is set.
        id: mygate
        with:
          inputsToCheck: 'NPM_TOKEN'
        env:
          NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
      - name: Install depencencies
        if: steps.mygate.outputs.inputsChecked == 'true'
        run: npm ci
      - name: Run tests
        if: steps.mygate.outputs.inputsChecked == 'true'
        run: npm run test
      - name: Semantic Release
        uses: cycjimmy/semantic-release-action@v2
        if: steps.mygate.outputs.inputsChecked == 'true'
        id: semantic
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          NPM_TOKEN: ${{ secrets.NPM_TOKEN }}