question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

By @isaac-martin in https://github.com/chromaui/action/issues/30:

Would love an option on this action to run the job inside a certain directory.

defaults:
  run:
    working-directory: web

We have a mono repo with the below dir structure

cms
web
 .storybook

Github actions need to live in the root - so currently we cant use this action and have to manually run chromatic using the script in our package.json I can implement this change if someone can point me in the right direction.


By wendylw in https://github.com/chromaui/action/issues/61:

# This is a basic workflow to help you get started with Actions

name: Chromatic

# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
  push:
    branches: master

defaults:
  run:
    working-directory: frontend

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
  # This workflow contains a single job called "build"
  test:
    env:
      EXTEND_ESLINT: true
    # The type of runner that the job will run on
    runs-on: ubuntu-latest

    # Steps represent a sequence of tasks that will be executed as part of the job
    steps:
      # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
      - uses: actions/checkout@v2
        with:
          fetch-depth: 0 # Required to retrieve git history
      - run: |
          EXTEND_ESLINT=true yarn && yarn build-storybook
      - uses: chromaui/action@v1
        with:
         token: ${{ secrets.GITHUB_TOKEN }}
         projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
         storybookBuildDir: ./storybook-static
Error: The "path" argument must be one of type string, Buffer, or URL. Received type object
Error: TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be one of type string, Buffer, or URL. Received type object
    at readFile (fs.js:295:10)
    at go$readFile (/home/runner/work/_actions/chromaui/action/v1/node_modules/graceful-fs/graceful-fs.js:118:14)
    at readFile (/home/runner/work/_actions/chromaui/action/v1/node_modules/graceful-fs/graceful-fs.js:115:12)
    at /home/runner/work/_actions/chromaui/action/v1/node_modules/universalify/index.js:8:12
    at new Promise (<anonymous>)
    at readFile (/home/runner/work/_actions/chromaui/action/v1/node_modules/universalify/index.js:7:14)
    at Object._readFile (/home/runner/work/_actions/chromaui/action/v1/node_modules/jsonfile/index.js:19:58)
    at Object._readFile [as readFile] (/home/runner/work/_actions/chromaui/action/v1/node_modules/universalify/index.js:20:45)
    at runChromatic (/home/runner/work/_actions/chromaui/action/v1/lib/main.js:66:42)
    at async Promise.all (index 0)
Error: The "path" argument must be one of type string, Buffer, or URL. Received type object

Also requested by another customer.

┆Issue is synchronized with this Asana task by Unito

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:19
  • Comments:11

github_iconTop GitHub Comments

8reactions
rasbencommented, Oct 29, 2021

I know this is an old issue, but personally it took a lot of trial and error before I got this working for me

I’ll put my learnings here - maybe it’ll help someone else 😃

I have a Drupal (CMS), with a theme folder where I had my package.json and .storybook (among other things) It lived in web/themes/custom/MYTHEME

I quickly found out that I had to move package.json out in the root of the git, or Chromatic would never work. Sigh.

In my package.json I could however do this:

  "config": {
    "themepath": "web/themes/custom/THEMENAME"
  },
  "scripts": {
    "build-storybook": "build-storybook --config-dir $npm_package_config_themepath/.storybook"
  }

So far so good!

Now for the Github Action:

.github/workflows/chromatic.yml
name: 'Chromatic Deployment'
# the event that will trigger the action
on: push

jobs:
  # Deploy Chromatic
  chromatic:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@v2
        with:
          fetch-depth: 0 # 👈 Required to retrieve git history

      - name: Setup Node
        uses: actions/setup-node@v2
        with:
          node-version: '16'

      - name: Cache dependencies
        uses: actions/cache@v2
        with:
          path: ~/.npm
          key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
          restore-keys: |
            ${{ runner.os }}-node-
      - run: npm install
      - run: npm run build
      - run: npm run build-storybook
      # Chromatic deployment
      - uses: chromaui/action@v1
        with:
          projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
          storybookBuildDir: storybook-static
          token: ${{ secrets.GITHUB_TOKEN }}
          workingDir: ./

Thank you all for your examples 😃 I would never have figured this out without this thread.

6reactions
yigityucecommented, Nov 7, 2020

Actually I implemented this on forked repo within the feature branch but to be honest I couldn’t have spare time to follow contribution guidelines and open a PR after doing those and probably I won’t have time to do that in near future.

Anyone can do these steps is more than welcome 😄

Here you can find the changes I did. Btw it works as expected.

https://github.com/chromaui/chromatic-cli/compare/next...yigityuce:feature/action-input-workingdir

Screenshot_3

Read more comments on GitHub >

github_iconTop Results From Across the Web

What is monorepo? (and should you use it?) - Semaphore CI
A monorepo is a version-controlled code repository that holds many projects. While these projects may be related, they are often logically ...
Read more >
Monorepo Explained
Gradle Build Tool provides support for parallel tasks via configuration, and task orchestration through its flexible Groovy or Kotlin DSL. natively supported ......
Read more >
Monorepos in Git | Atlassian Git Tutorial
A monorepo is a repository that contains more than one logical project. Read here to learn about conceptual challenges, performance issues and more....
Read more >
Monorepo Support | Render · Cloud Hosting for Developers
Monorepo Support helps you deploy just the services you need to eliminate unnecessary deploys, control build costs, and ship faster. Monorepo Support offers...
Read more >
A Guide to Monorepos for Front-end Code - Toptal
A monorepo or monorepository is a code management and architectural concept whereby you keep all your isolated bits of code inside one super...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found