GithubHelp home page GithubHelp logo

chromatic-github-action-monorepo's Introduction

Chromatic GitHub Action Monorepo Examples

This repository exists to highlight the configuration options for using the Chromatic GitHub Action in a monorepo.

Essentially, this comes down to two key steps.

  1. Use the workingDir input on the chromatic step
  2. Use working-directory on other steps so they run in the correct place as well

working-directory Options

There are three options for setting working-directory on your jobs. Be aware that this refers only to run steps, other steps will have their own specific inputs, much like Chromatic has workingDir. Please refer to their documentation directly for details.

Directly On Step

The first option is to place it directly into the run steps, like this.

    steps:
      - uses: actions/checkout@v1
      - name: Install dependencies
        run: yarn
        working-directory: marketing

The file .github/workflows/marketing.yaml is an example of this method.

Job Level Default

If you have multiple run steps in your job, a job level default would reduce repetition.

jobs:
  chromatic-frontend:
    runs-on: ubuntu-latest
    defaults:
      run:
        working-directory: frontend
    steps:
      - uses: actions/checkout@v1
      - name: Install dependencies
        run: yarn
      - name: Prebuild storybook
        run: yarn build-storybook

The file .github/workflows/frontend.yaml is an example of this method.

Workflow Level Default

Lastly, you can set it as a workflow level default. This would be useful if you have several jobs in the workflow that all need to run in the subdirectory.

name: 'Admin'

on: push

defaults:
  run:
    working-directory: admin

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v1
      - name: Install dependencies
        run: yarn
      - name: Run tests
        run: yarn test
  chromatic:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v1
      - name: Install dependencies
        run: yarn
      - name: Publish to Chromatic
        uses: chromaui/action@v1
        with:
          workingDir: admin
          token: ${{ secrets.GITHUB_TOKEN }}
          projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN_ADMIN }}

Why doesn't the Chromatic action use working-directory?

The working-directory keyword is specific to the run step, and is not exposed to the Chromatic action.

chromatic-github-action-monorepo's People

Contributors

jmhobbs avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.