.github/workflows/dashboard_ui.yaml

Summary

Maintainability
Test Coverage
name: Dashboard CI

on:
  push:
    branches:
      - '**'
    paths:
      - 'dashboard-ui/**'
      - '.github/workflows/dashboard_ui.yaml'
    tags:
      - '*'
  pull_request:
    branches:
      - master
      - develop
      - crons
      - workers
    paths:
      - 'dashboard-ui/**'

jobs:
  dashboard-ui:
    runs-on: ubuntu-18.04

    # name: Node ${{ matrix.node-version }}

    steps:
      # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
      - uses: actions/checkout@v2

      - name: Use Node.js 12.16.x
        uses: actions/setup-node@v1
        with:
          node-version: 12.16.x

      # https://github.com/actions/cache/blob/master/examples.md#node---yarn
      - name: Get yarn cache directory path
        id: yarn-cache-dir-path
        run: echo "::set-output name=dir::$(yarn cache dir)"

      - name: Cache Node.js modules
        id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
        uses: actions/cache@v1
        with:
          path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
          key: ${{ runner.os }}-yarn-dashboard-${{ hashFiles('dashboard-ui/**/yarn.lock') }}
          restore-keys: |
            ${{ runner.os }}-yarn-dashboard-${{ hashFiles('dashboard-ui/**/yarn.lock') }}
            ${{ runner.os }}-yarn-dashboard-
            ${{ runner.os }}-yarn-
      - name: Install
        run: |
          cd dashboard-ui
          yarn install --frozen-lockfile
      - name: Lint
        run: |
          cd dashboard-ui
          yarn lint
      - name: Build
        run: |
          cd dashboard-ui
          yarn build
      - name: Build docker image [push]
        if: github.event_name == 'push' && ( github.ref == 'refs/heads/master' || github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/apm' || github.ref == 'refs/heads/automations')
        run: |
          cd dashboard-ui
          echo ${{ secrets.DOCKERHUB_TOKEN }} | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin
          docker build -t erxes/erxes-dashboard-front:${GITHUB_REF#refs/heads/} -f Dockerfile .
          docker push erxes/erxes-dashboard-front:${GITHUB_REF#refs/heads/}
      - name: Build docker image [tag]
        if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
        run: |
          cd dashboard-ui
          echo ${{ secrets.DOCKERHUB_TOKEN }} | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin
          docker build -t erxes/erxes-dashboard-front:${GITHUB_REF#refs/tags/} -f Dockerfile .
          docker push erxes/erxes-dashboard-front:${GITHUB_REF#refs/tags/}