NaturalCycles/js-lib

View on GitHub
.github/workflows/ci.yml

Summary

Maintainability
Test Coverage
name: ci

on: [push, workflow_dispatch]

env:
  NODE_OPTIONS: --max-old-space-size=5000
  CC_TEST_REPORTER_ID: 7997607c5b558cb4d41dc064f3df1a81c07f2de9861ed73c738c23ed8dbab69e

jobs:
  build-job:
    runs-on: ubuntu-latest
    if: "!contains(github.event.head_commit.message , 'skip ci')"
    steps:
      - { uses: actions/checkout@v4, with: { persist-credentials: false } }
      - { uses: actions/setup-node@v4, with: { node-version: 'lts/*', cache: 'yarn' } }
      - run: yarn --frozen-lockfile

      - name: build
        run: yarn build

      - name: test
        run: |
          curl -s -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter && chmod +x ./cc-test-reporter
          ./cc-test-reporter before-build
          yarn test
          ./cc-test-reporter after-build -t lcov

  release-job:
    runs-on: ubuntu-latest
    if: github.ref_name == 'master'
    permissions:
      contents: write
      id-token: write
    steps:
      - { uses: actions/checkout@v4, with: { persist-credentials: true } }
      - { uses: actions/setup-node@v4, with: { node-version: 'lts/*', cache: 'yarn' } }

      # Cache for npm/npx in ~/.npm
      - uses: actions/cache@v4
        with:
          path: ~/.npm
          key: npm-v1-${{ runner.os }}

      - run: yarn --frozen-lockfile
      - run: yarn build-prod

      - name: release
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
        run: npx @naturalcycles/semantic-release

  docs-job:
    runs-on: ubuntu-latest
    if: github.ref_name == 'master'
    steps:
      - { uses: actions/checkout@v4, with: { persist-credentials: false } }
      - { uses: actions/setup-node@v4, with: { node-version: 'lts/*', cache: 'yarn' } }
      - run: yarn --frozen-lockfile

      - name: docs-build
        run: yarn docs-build

      - name: publish docs to github pages
        uses: peaceiris/actions-gh-pages@v4
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          publish_dir: ./docs/.vitepress/dist
          force_orphan: true
          commit_message: 'deploy docs [skip ci]'
          # publish_branch: gh-pages