victorpopkov/universal-redux

View on GitHub
.github/workflows/ci.yml

Summary

Maintainability
Test Coverage
name: CI

on:
  push:
    branches:
      - develop
      - main
  pull_request:
    branches:
      - develop
      - main

permissions: read-all

env:
  NODE_ENV: development
  SLACK_CHANNEL: ${{ secrets.SLACK_CHANNEL }}
  SLACK_SIGNING_SECRET: ${{ secrets.SLACK_SIGNING_SECRET }}
  SLACK_TOKEN: ${{ secrets.SLACK_TOKEN }}

jobs:
  build:
    runs-on: ubuntu-latest
    timeout-minutes: 15
    strategy:
      matrix:
        node_version: [18.12.0]
    steps:
      - name: Check out
        uses: actions/checkout@v4
      - name: Set up Node.js ${{ matrix.node_version }}
        uses: actions/setup-node@v4
        id: node
        with:
          node-version: ${{ matrix.node_version }}
      - name: Enable corepack
        run: corepack enable
      - name: Send Slack notification
        uses: codedsolar/slack-action@v1
        if: ${{ github.event_name != 'pull_request' }}
        id: slack
        with:
          status: in-progress
          fields: |
            {STATUS}
            {REF}
            Node.js: ${{ steps.node.outputs.node-version }}
      - name: Install dependencies
        run: yarn install --ignore-scripts
      - name: Build
        run: yarn build
        env:
          NODE_ENV: production
      - name: Update Slack notification
        uses: codedsolar/slack-action@v1
        if: ${{ github.event_name != 'pull_request' && always() }}
        with:
          status: ${{ job.status }}
          timestamp: ${{ steps.slack.outputs.slack-timestamp }}
          fields: |
            {STATUS}
            {REF}
            Node.js: ${{ steps.node.outputs.node-version }}

  lint:
    runs-on: ubuntu-latest
    timeout-minutes: 15
    strategy:
      matrix:
        node_version: [18.12.0]
    steps:
      - name: Check out
        uses: actions/checkout@v4
      - name: Set up Node.js ${{ matrix.node_version }}
        uses: actions/setup-node@v4
        id: node
        with:
          node-version: ${{ matrix.node_version }}
      - name: Enable corepack
        run: corepack enable
      - name: Send Slack notification
        uses: codedsolar/slack-action@v1
        if: ${{ github.event_name != 'pull_request' }}
        id: slack
        with:
          status: in-progress
          fields: |
            {STATUS}
            {REF}
            Node.js: ${{ steps.node.outputs.node-version }}
            ESLint issues: Checking...
            Prettier issues: Checking...
      - name: Install dependencies
        run: yarn install --ignore-scripts
      - name: Lint
        id: lint
        run: |
          yarn ci:eslint || true
          yarn ci:prettier || true
          yarn lint || true
      - name: Lint results
        id: lint-results
        run: |
          export LINT_ISSUES=$((${{ steps.lint.outputs.eslint-issues || 0 }} + ${{ steps.lint.outputs.prettier-issues || 0 }}))
          if [ "${LINT_ISSUES}" -eq 0 ]; then exit 0; else exit 1; fi
      - name: Update Slack notification
        uses: codedsolar/slack-action@v1
        if: ${{ github.event_name != 'pull_request' && always() }}
        with:
          status: ${{ job.status }}
          timestamp: ${{ steps.slack.outputs.slack-timestamp }}
          fields: |
            {STATUS}
            {REF}
            Node.js: ${{ steps.node.outputs.node-version }}
            ESLint issues: ${{ steps.lint.outputs.eslint-issues || 'Skipped' }}
            Prettier issues: ${{ steps.lint.outputs.prettier-issues || 'Skipped' }}