devlato/async-wait-until

View on GitHub
.github/workflows/publish.yml

Summary

Maintainability
Test Coverage
name: Publish

on:
  push:
    tags:
      - '*'
  workflow_dispatch: {}

jobs:
  lint:
    name: Lint
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4
        with:
          set-safe-directory: 'true'
      - name: Install dependencies
        run: npm ci --ignore-scripts
      - name: Lint the codebase
        run: npm run lint:ci
  test:
    name: Tests
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4
        with:
          set-safe-directory: 'true'
      - name: Install dependencies
        run: npm ci --ignore-scripts
      - name: Run tests
        run: npm run test:ci
      - name: Upload coverage
        uses: actions/upload-artifact@v4
        with:
          name: test_coverage
          path: coverage
  build_code:
    name: Build code
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4
        with:
          set-safe-directory: 'true'
      - name: Install dependencies
        run: npm ci --ignore-scripts
      - name: Run tests
        run: npm run build:ci
      - name: Upload dist
        uses: actions/upload-artifact@v4
        with:
          name: dist
          path: dist
  integration_tests:
    name: Run integration tests
    runs-on: ubuntu-latest
    needs: build_code
    steps:
      - name: Checkout
        uses: actions/checkout@v4
        with:
          set-safe-directory: 'true'
      - name: Install dependencies
        run: npm ci --ignore-scripts
      - name: Download dist/ folder
        uses: actions/download-artifact@v4
        with:
          name: dist
          path: dist
      - name: Run integration tests
        run: npm run test:integration:ci
  build_docs:
    name: Build Docs
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4
      - name: Install dependencies
        run: npm ci --ignore-scripts
      - name: Build storybook
        run: npm run docs:ci
      - name: Upload the storybook
        uses: actions/upload-artifact@v4
        with:
          name: docs
          path: docs
  deploy_docs:
    needs: build_docs
    name: Deploy docs
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4
        with:
          set-safe-directory: 'true'
      - name: Install dependencies
        run: npm ci --ignore-scripts
      - name: Download storybook
        uses: actions/download-artifact@v4
        with:
          name: docs
          path: docs
      - name: Fetch all
        run: git fetch --all
      - name: Get the latest tag version
        id: get-last-tag
        run: |
          last_tag=$( git describe --tags --abbrev=0 )
          echo "::set-output name=LAST_TAG::${last_tag}"
      - name: Deploy Docs to GitHub Pages
        uses: crazy-max/ghaction-github-pages@v4
        with:
          target_branch: '${{ secrets.DOCS_TARGET_BRANCH }}'
          build_dir: docs
          author: '${{ secrets.AUTOCOMMITTER_NAME }} <${{ secrets.AUTOCOMMITTER_EMAIL }}>'
          commit_message: 'Update docs for package v${{ steps.get-last-tag.LAST_TAG }}'
        env:
          GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
          GITHUB_PAT: '${{ secrets.GH_PAT }}'
  publish:
    needs: [lint, test, build_code, build_docs, integration_tests]
    name: Publish to npm
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4
        with:
          set-safe-directory: 'true'
      - name: Install dependencies
        run: npm ci --ignore-scripts
      - name: Publish
        run: |
          echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > .npmrc
          npm publish
        env:
          GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
          NPM_TOKEN: '${{ secrets.NPM_AUTH_TOKEN }}'