From 7665bf3bb2eca1fa592d5f1d4d2fd60532b06696 Mon Sep 17 00:00:00 2001 From: John Hobbs Date: Wed, 5 May 2021 17:08:09 -0500 Subject: [PATCH] Add documentation for workingDir and monorepo usage. --- action/README.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/action/README.md b/action/README.md index 04a03fc73..5712bba94 100755 --- a/action/README.md +++ b/action/README.md @@ -49,6 +49,7 @@ Make sure to replace the value of `projectToken` with the project token provided token: ${{ secrets.GITHUB_TOKEN }} projectToken: 'Your chromatic project token' buildScriptName: 'The npm script that builds your Storybook [build-storybook]' + workingDir: 'Working directory for the package.json file' storybookBuildDir: 'Provide a directory with your built storybook; use if you've already built your storybook' allowConsoleErrors: 'Do not exit when runtime errors occur in storybook' autoAcceptChanges: 'Automatically accept all changes in chromatic: boolean or branchname' @@ -68,6 +69,32 @@ We suggest you use a secret to hide the project token: You can to configure secrets in the repository settings (`///settings/secrets`). However if you need to be able to run this action on pull requests from forks, because those can't access your secret. +### Monorepo Support + +The `workingDir` input can be used to direct Chromatic to a subdirectory where your Storybook exists. You will also need to provide this directory to other steps in your job, as needed. This can be done per-step, or with top-level defaults for `run` steps using [defaults.run](https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#defaultsrun) or [jobs..defaults.run](https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_iddefaultsrun) + +```yaml +jobs: + chromatic-deployment: + runs-on: ubuntu-latest + defaults: + run: + working-directory: frontend + steps: + - uses: actions/checkout@v1 + - name: Install dependencies + run: yarn + # 👇 Runs yarn in ./frontend + working-directory: frontend + - name: Publish to Chromatic + uses: chromaui/action@v1 + with: + # 👇 Runs Chromatic CLI in ./frontend + workingDir: frontend + token: ${{ secrets.GITHUB_TOKEN }} + projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }} +``` + ### Outputs | Name | Type | Description |