name: 'Chromatic'
on:
  workflow_dispatch:
  push:
    branches:
      - develop

jobs:
  chromatic-deployment:
    runs-on: ubuntu-latest
    env:
      STORYBOOK_FREEZE_DATE: "true"
    steps:
      - uses: actions/checkout@v1
      - name: Setup Node.js
        uses: actions/setup-node@v2
        with:
          node-version: "14"
      - name: Install dependencies
        run: yarn
      - name: Publish to Chromatic
        if: github.ref != 'refs/heads/develop'
        uses: chromaui/action@v1
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
          exitZeroOnChanges: true
      - name: Publish to Chromatic and auto accept changes
        if: github.ref == 'refs/heads/develop'
        uses: chromaui/action@v1
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
          autoAcceptChanges: true

name: 'Chromatic'
on:
  pull_request:
    types:
      - labeled
  push:
    branches:
      - develop

jobs:
  chromatic-deployment:
    if: contains(github.event.pull_request.labels.*.name, 'run-VR')
    runs-on: ubuntu-latest
    env:
      STORYBOOK_FREEZE_DATE: "true"
    steps:
      - uses: actions/checkout@v1
      - name: Setup Node.js
        uses: actions/setup-node@v2
        with:
          node-version: "14"
      - name: Install dependencies
        run: yarn
      - name: Publish to Chromatic
        if: github.ref != 'refs/heads/develop'
        uses: chromaui/action@v1
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
          exitZeroOnChanges: true
      - name: Publish to Chromatic and auto accept changes
        if: github.ref == 'refs/heads/develop'
        uses: chromaui/action@v1
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
          autoAcceptChanges: true

Add an experimental GH actions step which lets run Chromatic with label
[DDW-844] Add an experimental GH actions step which lets run Chromatic with label
