name: Node CI for app production

on:
  push:
    branches:
      - master
    paths:
      - .github/workflows/ci-app-prod.yml
      - .github/workflows/reusable-app-prod.yml
      - .github/workflows/reusable-app-reg-suit.yml
      - tsconfig.base.json
      - yarn.lock
      - packages/app/**
      - '!packages/app/docker/**'
      - packages/codemirror-textlint/**
      - packages/core/**
      - packages/remark-*/**
      - packages/slack/**
      - packages/ui/**
  pull_request:
    branches:
      - master
    types: [opened, reopened, synchronize]
    paths:
      - .github/workflows/ci-app-prod.yml
      - .github/workflows/reusable-app-prod.yml
      - .github/workflows/reusable-app-reg-suit.yml
      - tsconfig.base.json
      - yarn.lock
      - packages/app/**
      - '!packages/app/docker/**'
      - packages/codemirror-textlint/**
      - packages/core/**
      - packages/remark-*/**
      - packages/slack/**
      - packages/ui/**
  workflow_call:
    inputs:
      cypress-config-video:
        description: 'Enable video when running Cypress test'
        type: boolean
        default: false

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true


jobs:

  test-prod-node14:
    uses: weseek/growi/.github/workflows/reusable-app-prod.yml@master
    with:
      node-version: 14.x
      skip-cypress: true
    secrets:
      SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}


  test-prod-node16:
    uses: weseek/growi/.github/workflows/reusable-app-prod.yml@master
    with:
      node-version: 16.x
      skip-cypress: ${{ contains( github.event.pull_request.labels.*.name, 'dependencies' ) }}
      cypress-report-artifact-name: Cypress report
      cypress-config-video: ${{ inputs.cypress-config-video || false }}
    secrets:
      SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}


  run-reg-suit-node16:
    needs: [test-prod-node16]

    uses: weseek/growi/.github/workflows/reusable-app-reg-suit.yml@master

    if: always()

    with:
      node-version: 16.x
      skip-reg-suit: ${{ contains( github.event.pull_request.labels.*.name, 'dependencies' ) }}
      cypress-report-artifact-name: Cypress report
    secrets:
      REG_NOTIFY_GITHUB_PLUGIN_CLIENTID: ${{ secrets.REG_NOTIFY_GITHUB_PLUGIN_CLIENTID }}
      AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
      AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
      SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
