sshivananda/ts-sqs-consumer

View on GitHub
.github/workflows/nodejs.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
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Node.js CI

on:
  push:
    branches:
      - '*'
      - master
      - release/*
      - feature/*
      - bugfix/*
  pull_request:
    branches: [ master ]

jobs:
  build:

    runs-on: ${{ matrix.os }}
    env:
      SERVICES: sqs,dynamodb
      AWS_ACCESS_KEY_ID: fake
      AWS_SECRET_ACCESS_KEY: fake
      AWS_DEFAULT_REGION: local

    strategy:
      matrix:
        os: [ubuntu-latest, windows-latest, macOS-latest]
        node-version: [12.x, 13.x]

    steps:
    - uses: actions/checkout@v2
    - name: Use Node.js ${{ matrix.node-version }} on ${{ matrix.os }}
      uses: actions/setup-node@v1
      with:
        node-version: ${{ matrix.node-version }}
        registry-url: 'https://registry.npmjs.org'
    - name: Get npm cache directory
      id: npm-cache
      run: |
        echo "::set-output name=dir::$(npm config get cache)"
    - uses: actions/cache@v1
      with:
        path: ${{ steps.npm-cache.outputs.dir }}
        key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
        restore-keys: |
          ${{ runner.os }}-node-
    - run: npm ci
    - run: npm run build
    - run: npm run coverage
    - run: npm run run-integration-test
      if: ${{runner.os == 'Linux'}}
    - run: npm run can-publish
      if: ${{ runner.os == 'Linux' && matrix.node-version == '12.x' }}
    - uses: paambaati/codeclimate-action@v2.6.0
      env:
        CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
      with:
        coverageCommand: npm run coverage
      if: ${{ github.repository == 'sshivananda/ts-sqs-consumer' && runner.os == 'Linux' && matrix.node-version == '12.x'}}
    - name: Self sast-scan NodeJS
      uses: AppThreat/sast-scan-action@master
      if: ${{ runner.os == 'Linux' }}
      with:
        src: "/github/workspace/dist"
        output: "/github/workspace/reports"
        type: nodejs
    - uses: actions/upload-artifact@v1
      if: ${{ runner.os == 'Linux' }}
      with:
        name: reports
        path: reports
    - name: package-version-to-git-tag
      uses: pkgdeps/action-package-version-to-git-tag@v1
      if: ${{ github.ref == 'refs/heads/master' && runner.os == 'Linux' && matrix.node-version == '12.x' }}
      with:
        github_token: ${{ secrets.GITHUB_TOKEN }}
        github_repo: ${{ github.repository }}
        git_commit_sha: ${{ github.sha }}
    - run: npm publish --access public
      if: ${{ github.ref == 'refs/heads/master' && runner.os == 'Linux' && matrix.node-version == '12.x' }}
      env:
        NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}