Laserphile/JS-Telecortex-2-Server

View on GitHub
.github/workflows/node-ci.yml

Summary

Maintainability
Test Coverage
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node

name: Node.js CI

on: [push, pull_request]

jobs:
  build:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        node-version: [10.x, 11.x, 12.x, 14.x]

    steps:
      - uses: actions/checkout@v2
      - name: Setup Node.js ${{ matrix.node-version }}
        uses: actions/setup-node@v1
        with:
          node-version: ${{ matrix.node-version }}
      - run: npm ci
      - run: npm run test:ci
      - run: npm run coverage
      - run: npm run build
      - run: npm run test:build

  coverage:
    needs: build
    runs-on: ubuntu-latest
    env:
      CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v1
        with:
          node-version: 12
          registry-url: https://registry.npmjs.org/
      - run: npm ci
      - run: npm run test:ci
      - run: npm run coverage

  deploy:
    needs: build
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v1
        with:
          node-version: 12
          registry-url: https://registry.npmjs.org/
      - run: npm ci
      - name: Install Balena SSH key
        uses: shimataro/ssh-key-action@v2
        with:
          key: ${{ secrets.BALENA_CLOUD_PRIVATE_KEY }}
          known_hosts: ${{ secrets.BALENA_KNOWN_HOSTS }}
      - name: publish balena image
        run: |
          git config --global user.name "GitHub Action"
          git config --global user.email "email@example.com"
          git remote add balena ${{ secrets.BALENA_REMOTE  }}
          git fetch --unshallow origin
          git commit -am "build" --allow-empty
          git push -f balena master