Code Monkey home page Code Monkey logo

kms-ci-public's Introduction

GitHub Action for Chromatic

Builds and publishes your Storybook to Chromatic and runs visual regression tests.

This is a wrapper for chromatic-cli, which is also where the action's source code resides.

Getting started

In your git repository, create a file .github/workflows/chromatic.yml with the following contents:

# .github/workflows/chromatic.yml

# Workflow name
name: 'Chromatic'

# Event for the workflow
on: push

# List of jobs
jobs:
  chromatic-deployment:
    # Operating System
    runs-on: ubuntu-latest
    # Job steps
    steps:
      - uses: actions/checkout@v1
      - name: Install dependencies
        run: yarn
        # ๐Ÿ‘‡ Adds Chromatic as a step in the workflow
      - name: Publish to Chromatic
        uses: chromaui/action@v1
        # Chromatic GitHub Action options
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          # ๐Ÿ‘‡ Chromatic projectToken, refer to the manage page to obtain it.
          projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}

Make sure to replace the value of projectToken with the project token provided to you by Chromatic. You can find it on the Manage page of your Chromatic project. The GitHub token is unrelated and will be set automatically. See below if you want to keep your projectToken secret.

Note: Chromatic requires full git history, so if you are using the action/checkout@v2 action, ensure you set the fetch-depth: 0 option.

Usage

- uses: chromaui/action@v1
  with:
    token: ${{ secrets.GITHUB_TOKEN }}
    projectToken: 'Your chromatic project token'
    buildScriptName: 'The npm script that builds your Storybook [build-storybook]'
    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'
    exitZeroOnChanges: 'Positive exit of action even when there are changes: boolean or branchname'
    exitOnceUploaded: 'Exit with 0 once the built version has been sent to chromatic: boolean or branchname'
    ignoreLastBuildOnBranch: 'Ignores latest build on target branch as a baseline if branch is no longer present in history (i.e. branch was rebased): branchname'

We suggest you use a secret to hide the project token:

- uses: chromaui/action@v1
  with:
    token: ${{ secrets.GITHUB_TOKEN }}
    projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}

You can to configure secrets in the repository settings (/<owner>/<repository>/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.

Outputs

Name Type Description
url string An alias for the build URL (e.g. https://www.chromatic.com/build?appId=<app id goes here>&number=<build number>)
buildUrl string The build URL (e.g. https://www.chromatic.com/build?appId=<app id goes here>&number=<build number>)
storybookUrl string The Storybook preview URL for your current branch / Pull Request (e.g. https://<app id goes here>-<branch hash>.chromatic.com/)
code string The exit code for the current run of the Chromatic CLI

Checkout depth

Version 2 of the actions/checkout action will only checkout a single commit without history by default. Chromatic needs the full git history in order to track changes over time. Set fetch-depth: 0 to enable this. See actions/checkout for details.

Issues and support

Please report any issues in the chromatic-cli repository. We provide documentation and support chat at https://www.chromatic.com/docs/.

kms-ci-public's People

Contributors

foxbrown avatar

Watchers

Zohar Babin avatar James Cloos avatar KCorpIT avatar  avatar Kaltura GitHub Hooks 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.