weixu365/serverless-scriptable-plugin

View on GitHub
.github/workflows/build.yml

Summary

Maintainability
Test Coverage
name: Build

on:
  push:
    branches: [ master, '*' ]
  pull_request:
    branches: [ master, '*' ]

env:
  GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
  NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

jobs:
  Test:
    name: Unit Test
    runs-on: ubuntu-latest
    strategy:
      matrix:
        node-version: [18]

    steps:
      - uses: actions/checkout@v4
      - name: Use Node.js ${{ matrix.node-version }}
        uses: actions/setup-node@v4
        with:
          node-version: ${{ matrix.node-version }}
      - run: npm ci
      - run: curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
      - run: chmod +x ./cc-test-reporter && ./cc-test-reporter before-build
      - run: npm test
        env: 
          CI: Github_Action
          TRAVIS: 1
      - run: ./cc-test-reporter after-build -t lcov || true

  Release:
    name: Publish to npm
    runs-on: ubuntu-latest
    needs: Test
    if: github.ref == 'refs/heads/master'
    strategy:
      matrix:
        node-version: [20]

    steps:
      - uses: actions/checkout@v4
      - name: Use Node.js ${{ matrix.node-version }}
        uses: actions/setup-node@v4
        with:
          node-version: ${{ matrix.node-version }}
      - run: npm ci
      - run: npm run semantic-release