Git Product home page Git Product logo

storybook-deployer's Introduction

Storybook Deployer

This is a simple tool allows you to deploy your Storybook into a static hosting service. (Currently, GitHub Pages and AWS S3 beta)

$ storybook-to-ghpages --help
$ storybook-to-aws-s3 --help

Options:
  --help, -h                      Show help.                                             [boolean]
  --version                       Show version number                                    [boolean]
  --existing-output-dir, -e       If you have previously built your storybook output (through a
                                  different CI step, etc) and just need to publish it     [string]
  --out, -o                       Configure the output directory                          [string]
  --packages, -p                  Directory for package.jsons (monorepo support)          [string]
  --monorepo-index-generator, -m  Path to file to customize the monorepo index.html. This function
                                  should return the html for the page.                    [string]
  --script, -s                    Specify the build script in your package.json           [string]
  --ci                            Deploy the storybook in CI mode (github only)          [boolean]
  --dry-run                       Run build but hold off on publishing                   [boolean]
  --remote                        Git remote to push to               [string] [default: "origin"]
  --branch                        Git branch to push to             [string] [default: "gh-pages"]
  --source-branch                 Source branch to push from          [string] [default: "master"]
  --host-token-env-variable, -t   Github token for CI publish       [string] [default: "GH_TOKEN"]
  --aws-profile                   AWS profile to use for publishing. Use NONE to use no profile
                                  at all instead of "default".       [string] [default: "default"]
  --bucket-path                   AWS bucket path to use for publishing                   [string]
  --s3-sync-options               Additional options to pass to AWSCLI s3 sync            [string]

Getting Started

Install Storybook Deployer with:

npm i @storybook/storybook-deployer --save-dev

Then add a NPM script like this for github page:

{
  "scripts": {
    "deploy-storybook": "storybook-to-ghpages"
  }
}

or like this for AWS S3:

{
  "scripts": {
    "deploy-storybook": "storybook-to-aws-s3"
  }
}

Then you can run npm run deploy-storybook to deploy the Storybook.

Alternatively, you can execute Storybook Deployer directly using npx

npx -p @storybook/storybook-deployer storybook-to-ghpages
npx -p @storybook/storybook-deployer storybook-to-aws-s3

Custom Build Configuration

If you customize the build configuration with some additional params (like static file directory), then you need to expose another NPM script like this:

{
  "scripts": {
    "build-storybook": "build-storybook -s public"
  }
}

Configure Build Directory

If you need to configure the output directory you can supply the out flag.

npm run deploy-storybook -- --out=.out

Skip Build Step

If you have previously built your storybook output (through a different CI step, etc) and just need to publish it, specify the directory like this:

npm run deploy-storybook -- --existing-output-dir=.out

Skip Deploy Step

if you want to see how everything build without pushing to a remote, use the --dry-run flag.

npm run deploy-storybook -- --dry-run

Deploy a Monorepo

If you manage a monorepo with multiple storybooks you can pass the packages flag to deploy-storybook to scan a directory for package.jsons.

The following command will search the packages directory for packages. It will also generate a default index.html that links to all of the loaded storybooks.

npm run deploy-storybook -- --packages packages

Customize Monorepo index.html

To customize the monorepo index.html you can pass the monorepo-index-generator flag to deploy-storybook. This file should export a function that receive the following arguments and returns the html for the page.

  • an array of all the package.json data from the loaded storybooks as the first argument
  • the output directory
npm run deploy-storybook -- --monorepo-index-generator my-custom-generator.js

Deploying Storybook as part of a CI service

To deploy Storybook as part of a CI step, pass the ci flag to npm run deploy-storybook.

If the CI environment variable is set then this mode will be assumed, therefore no need to specify the ci flag.

Because pushing to GitHub as part of a CI step requires a personal access token, Storybook uses the GH_TOKEN environment variable, by default, to authenticate GitHub pushes.

This environment variable name can be configured via the host-token-env-variable flag.

For example, if your access token is stored in the GH_TOKEN environment variable

npm run deploy-storybook -- --ci

Or if your access token is stored in the GITHUB_TOKEN environment variable

npm run deploy-storybook -- --ci --host-token-env-variable=GITHUB_TOKEN

Deploying Storybook to GitHub Pages as part of a GitHub Action

If you are deploying Storybook to GitHub Pages from a repository belonging to an organization account on GitHub, you may need to specify a ${{ github.actor }} in addition to the ${{ secrets.GITHUB_TOKEN }} for your build step to be able to authenticate properly.

For instance:

- name: Deploy storybook to GitHub Pages
  run: npm run deploy-storybook -- --ci
  env:
    GH_TOKEN: ${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}

Custom deploy configuration

If you want to customize Git username, email or commit message, add this to package.json:

"storybook-deployer": {
  "gitUsername": "Custom Username",
  "gitEmail": "[email protected]",
  "commitMessage": "Deploy Storybook [skip ci]"
}

It will override the default configuration:

"storybook-deployer": {
  "gitUsername": "GH Pages Bot",
  "gitEmail": "[email protected]",
  "commitMessage": "Deploy Storybook to GitHub Pages"
}

To deploy Storybook to a remote other than origin, pass a --remote flag to npm run deploy-storybook. For example, to deploy to your upstream remote:

npm run deploy-storybook -- --remote=upstream

Or, to specify a target branch and serve your storybook with rawgit instead of gh-pages:

npm run deploy-storybook -- --branch=feature-branch

Or, to specify a source branch other than master, pass a --source-branch flag to npm run deploy-storybook:

npm run deploy-storybook -- --source-branch=release

Custom deploy configuration for S3

For AWS S3 deployment you must have awscli installed.

You must specify a bucket path with bucket-path option: my-bucket-name/path/to/destination-folder-in-bucket and have the rights to write to this bucket.

You can change the aws profile used to run the command with the aws-profile option.

storybook-to-aws-s3 --bucket-path=my-bucket-name/path/to/destination-folder-in-bucket --aws-profile=myprofile

You can exclude the aws profile by setting this flag to "NONE":

storybook-to-aws-s3 --bucket-path=my-bucket-name/path/to/destination-folder-in-bucket --aws-profile=NONE

You can provide arbitrary S3 sync options via the --s3-sync-options flag:

storybook-to-aws-s3 --bucket-path=bucket-name/bucket-path --s3-sync-options=--acl=public-read
storybook-to-aws-s3 --bucket-path=bucket-name/bucket-path --s3-sync-options="--acl=public-read --quiet"

Contributors โœจ

Thanks goes to these wonderful people (emoji key):


Andrew Lisowski

๐Ÿ’ป ๐Ÿ“–

Arunoda Susiripala

๐Ÿ’ป ๐Ÿ“–

Norbert de Langen

๐Ÿ’ป ๐Ÿ“–

Dan Dean

๐Ÿ’ป ๐Ÿ“–

Jason Unger

๐Ÿ’ป ๐Ÿ“–

nkov

๐Ÿ’ป ๐Ÿ“–

Tyler Sargent

๐Ÿ“–

Patrick Riley

๐Ÿ’ป ๐Ÿ“–

jeanlucc

๐Ÿ’ป

Travis Bloom

๐Ÿ’ป

Christophe Coevoet

๐Ÿšง

Michael Shilman

๐Ÿšง

Jae Bradley

๐Ÿ’ป

Bryce Dorn

๐Ÿ›

Bao Pham

๐Ÿ’ป

Ankur Patel

๐Ÿ’ป

ZitaNemeckova

๐Ÿ’ป

Lucas Machado

๐Ÿ’ป

Jeri Sommers

๐Ÿ’ป

Jimmy Andrade

๐Ÿš‡ ๐Ÿ“– ๐Ÿ’ป

Nick Perez

๐Ÿ“– ๐Ÿ’ป

Mitchell

๐Ÿ“–

erlendmiljo

๐Ÿ“–

This project follows the all-contributors specification. Contributions of any kind welcome!

storybook-deployer's People

Contributors

arunoda avatar arunodakadira avatar boughtmanatee5 avatar dandean avatar dependabot[bot] avatar dominik-stypula-polcode avatar fraserkillip avatar georgewrmarshall avatar hipstersmoothie avatar imgbotapp avatar jackhowa avatar jaebradley avatar jeanlucc avatar jimmyandrade avatar jsonunger avatar luksm avatar mitchiemt11 avatar ndelangen avatar nkov avatar nperez0111 avatar orta avatar priley86 avatar shilman avatar skylarmb avatar sojeri avatar stephenhmarsh avatar travisbloom avatar tsargent avatar usulpro avatar zitanemeckova avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

storybook-deployer's Issues

Fails on GitHub Enterprise

No idea what the issue is. Does this create a git branch for you locally? Do you need one? Some error message would be helpful.

โฏ npm run storybook:deploy

> @watson-iot/[email protected] storybook:deploy /Users/kevinSuttle/Code/platform-ui-primitives
> storybook-to-ghpages

=> Building storybook
/Users/kevinSuttle/Code/platform-ui-primitives/node_modules/@kadira/storybook-deployer/src/utils.js:15
  throw new Error(message);
  ^

Error: Exec code(1) on executing: node ./node_modules/.bin/build-storybook -o .out
undefined
    at Object.exec (/Users/kevinSuttle/Code/platform-ui-primitives/node_modules/@kadira/storybook-deployer/src/utils.js:15:9)
    at Object.<anonymous> (/Users/kevinSuttle/Code/platform-ui-primitives/node_modules/@kadira/storybook-deployer/bin/storybook_to_ghpages:24:16)
    at Module._compile (module.js:541:32)
    at Object.Module._extensions..js (module.js:550:10)
    at Module.load (module.js:458:32)
    at tryModuleLoad (module.js:417:12)
    at Function.Module._load (module.js:409:3)
    at Module.runMain (module.js:575:10)
    at run (node.js:348:7)
    at startup (node.js:140:9)

npm ERR! Darwin 15.5.0
npm ERR! argv "/Users/kevinSuttle/.nvm/versions/node/v6.2.2/bin/node" "/Users/kevinSuttle/.nvm/versions/node/v6.2.2/bin/npm" "run" "storybook:deploy"
npm ERR! node v6.2.2
npm ERR! npm  v3.9.5
npm ERR! code ELIFECYCLE
npm ERR! @watson-iot/[email protected] storybook:deploy: `storybook-to-ghpages`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @watson-iot/[email protected] storybook:deploy script 'storybook-to-ghpages'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the @watson-iot/platform-ui-primitives package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     storybook-to-ghpages
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs @watson-iot/platform-ui-primitives
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls @watson-iot/platform-ui-primitives
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/kevinSuttle/Code/platform-ui-primitives/npm-debug.log

The --source-branch Flag Throws Error

We've changed our default branch name from master to main because of the slavery connotations.

Storybook-deployer no longer works, even with --source-branch=main passed as an argument.

package.json

scripts": {
	...
	"deploy-storybook": "storybook-to-ghpages",
	...
},
stephen@stephen Marble % npm run deploy-storybook --  --source-branch=main 

> [email protected] deploy-storybook /Users/stephen/dev/Marble
> storybook-to-ghpages "--source-branch=main"

=> Getting the git remote URL
   executing: git config --get remote.origin.url
=> Building storybook for: marble
   executing: npm run build-storybook -- -o out9943
   executing: git init
   executing: git config user.name "GH Pages Bot"
   executing: git config user.email "[email protected]"
   executing: git config commit.gpgsign false
   executing: git add .
   executing: git commit -m "Deploy Storybook to GitHub Pages"
=> Deploying storybook
   executing: git push --force --quiet https://github.com/metmuseum/Marble.git main:gh-pages
/Users/stephen/dev/Marble/node_modules/@storybook/storybook-deployer/src/utils.js:14
  throw new Error(
  ^

Error: Exec code(1) on executing: git push --force --quiet https://github.com/metmuseum/Marble.git main:gh-pages
error: src refspec main does not match any
error: failed to push some refs to 'https://github.com/metmuseum/Marble.git'

    at Object.exec (/Users/stephen/dev/Marble/node_modules/@storybook/storybook-deployer/src/utils.js:14:9)
    at Object.<anonymous> (/Users/stephen/dev/Marble/node_modules/@storybook/storybook-deployer/bin/storybook_to_ghpages:69:14)
    at Module._compile (internal/modules/cjs/loader.js:955:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10)
    at Module.load (internal/modules/cjs/loader.js:811:32)
    at Function.Module._load (internal/modules/cjs/loader.js:723:14)
    at Function.Module.runMain (internal/modules/cjs/loader.js:1043:10)
    at internal/main/run_main_module.js:17:11
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] deploy-storybook: `storybook-to-ghpages "--source-branch=main"`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] deploy-storybook script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/stephen/.npm/_logs/2020-06-29T18_55_53_541Z-debug.log

here is debug.log:

0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli   '/Users/stephen/.nvm/versions/node/v12.14.1/bin/node',
1 verbose cli   '/Users/stephen/.nvm/versions/node/v12.14.1/bin/npm',
1 verbose cli   'run',
1 verbose cli   'deploy-storybook',
1 verbose cli   '--',
1 verbose cli   '--source-branch=main'
1 verbose cli ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'predeploy-storybook', 'deploy-storybook', 'postdeploy-storybook' ]
5 info lifecycle [email protected]~predeploy-storybook: [email protected]
6 info lifecycle [email protected]~deploy-storybook: [email protected]
7 verbose lifecycle [email protected]~deploy-storybook: unsafe-perm in lifecycle true
8 verbose lifecycle [email protected]~deploy-storybook: PATH: /Users/stephen/.nvm/versions/node/v12.14.1/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Users/stephen/dev/Marble/node_modules/.bin:/Users/stephen/.nvm/versions/node/v12.14.1/bin:/Users/stephen/.rbenv/shims:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/share/dotnet:~/.dotnet/tools:/Applications/Visual Studio Code.app/Contents/Resources/app/bin
9 verbose lifecycle [email protected]~deploy-storybook: CWD: /Users/stephen/dev/Marble
10 silly lifecycle [email protected]~deploy-storybook: Args: [ '-c', 'storybook-to-ghpages "--source-branch=main"' ]
11 silly lifecycle [email protected]~deploy-storybook: Returned: code: 1  signal: null
12 info lifecycle [email protected]~deploy-storybook: Failed to exec deploy-storybook script
13 verbose stack Error: [email protected] deploy-storybook: `storybook-to-ghpages "--source-branch=main"`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (/Users/stephen/.nvm/versions/node/v12.14.1/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
13 verbose stack     at EventEmitter.emit (events.js:223:5)
13 verbose stack     at ChildProcess.<anonymous> (/Users/stephen/.nvm/versions/node/v12.14.1/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:223:5)
13 verbose stack     at maybeClose (internal/child_process.js:1021:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5)
14 verbose pkgid [email protected]
15 verbose cwd /Users/stephen/dev/Marble
16 verbose Darwin 19.5.0
17 verbose argv "/Users/stephen/.nvm/versions/node/v12.14.1/bin/node" "/Users/stephen/.nvm/versions/node/v12.14.1/bin/npm" "run" "deploy-storybook" "--" "--source-branch=main"
18 verbose node v12.14.1
19 verbose npm  v6.14.5
20 error code ELIFECYCLE
21 error errno 1
22 error [email protected] deploy-storybook: `storybook-to-ghpages "--source-branch=main"`
22 error Exit status 1
23 error Failed at the [email protected] deploy-storybook script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

It works fine without the flag:

stephen@stephen Marble % npm run deploy-storybook       
> [email protected] deploy-storybook /Users/stephen/dev/Marble
> storybook-to-ghpages

=> Getting the git remote URL
   executing: git config --get remote.origin.url
=> Building storybook for: marble
   executing: npm run build-storybook -- -o out4167
   executing: git init
   executing: git config user.name "GH Pages Bot"
   executing: git config user.email "[email protected]"
   executing: git config commit.gpgsign false
   executing: git add .
   executing: git commit -m "Deploy Storybook to GitHub Pages"
=> Deploying storybook
   executing: git push --force --quiet https://github.com/metmuseum/Marble.git master:gh-pages
=> Storybook deployed to: https://metmuseum.github.io/Marble/

Site hierarchy

It will be helpful to add the whole hierarchy rather that just the current output dir. In my use case, I have mono repo with more than just the Storybook site.

Typically, it involves the line:
publishUtils.exec('git add .');

to be replaced by:
publishUtils.exec('git -A add .');

Failed to exec deploy-storybook script

Describe the bug
No longer able to deploy to GH Pages. Previously I was able to simply run npm run deploy-storybook. Now when running the deploy command I run into the following error Failed to exec deploy-storybook script

To Reproduce

  1. Run the following: npm run deploy-storybook

Expected behavior
Successfully deploys updates to GH Pages

System
OS: macOS 10.15.6
CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
Binaries:
Node: 12.12.0 - ~/.nvm/versions/node/v12.12.0/bin/node
npm: 6.11.3 - ~/.nvm/versions/node/v12.12.0/bin/npm
Browsers:
Chrome: 89.0.4389.90
Firefox: 86.0.1
Safari: 14.0
npmPackages:
@storybook/addon-actions: 6.1.21 => 6.1.21
@storybook/addon-essentials: 6.1.21 => 6.1.21
@storybook/addon-links: 6.1.21 => 6.1.21
@storybook/addons: 6.1.21 => 6.1.21
@storybook/node-logger: 6.1.21 => 6.1.21
@storybook/preset-create-react-app: 3.1.7 => 3.1.7
@storybook/react: 6.1.21 => 6.1.21
@storybook/storybook-deployer: 2.8.7 => 2.8.7
@storybook/theming: 6.1.21 => 6.1.21

Additional context
Have been successfully deploying story book to GH Pages for months now without any issues. In the last week or so deploying to GH Pages is no longer working.

Deploy to monorepo subfolders

I have a monorepo containing a number of react components that i've built using storybook (IT'S AWESOME!).

I would like to generate GH Pages for each of them, however storybook-deployer seems to always deploy to the root of the mono repo for GH Pages instead of the currently active folder.

Could not read username for enterprise github

Hi team,
Thank you for building this awesome library.
I'm trying to use it for enterprise github by using the github api token in jenkins pipeline.
I've set up the user name in package.json

"storybook-deployer": {
    "gitUsername": "testName",
    "gitEmail": "testEmail",
    "commitMessage": "Deploy Storybook [skip ci]"
  }

And I got error below

> storybook-to-ghpages "--ci" "--host-token-env-variable=****"

=> Getting the git remote URL
   executing: git config --get remote.origin.url
=> Building storybook
   executing: node ./node_modules/.bin/build-storybook -o out2263
   executing: git init
   executing: git config user.name "testName"
   executing: git config user.email "testEmail"
   executing: git config commit.gpgsign false
   executing: git add .
   executing: git commit -m "Deploy Storybook [skip ci]"
=> Deploying storybook
   executing: git push --force --quiet https://github.enterprisename.com/testName/XXX-repo master:gh-pages
exec: fatal: could not read Username for 'https://github.enterprisename.com': No such device or address

Is there a way I can fix it?

Thank you!

Improve monorepo documentation on dependencies

Problem

In order to use storybook-deployer in a monorepo, you need to have the command build-storybook available in the monorepo root. It seems to come with @storybook/react and other storybook target libraries.

In a monorepo, you might have this dependency only available in a specific package where you use monorepo, and not in the monorepo root, where you run storybook-deployer.

Solution

List dependencies, at least under "Deploy a Monorepo" section, and explain in which package(s) the required command build-storybook comes.

It probably wouldn't hurt if there would be a list of required peer dependencies mentioned next to the installation instructions.

[Bug] custom SOURCE branch option doesn't work

Describe the bug

yarn run v1.21.1
$ yarn --cwd packages/storybook storybook-to-ghpages --source-branch=custom-branch
$ /home/project/node_modules/.bin/storybook-to-ghpages --source-branch=custom-branch
=> Getting the git remote URL
   executing: git config --get remote.origin.url
=> Building storybook for: @conversionxl/storybook
   executing: build-storybook  -o out1797
   executing: git init
   executing: git config user.name "GH Pages Bot"
   executing: git config user.email "[email protected]"
   executing: git config commit.gpgsign false
   executing: git add .
   executing: git commit -m "Deploy Storybook to GitHub Pages"
=> Deploying storybook
   executing: git push --force --quiet [email protected]:dominik-stypula-polcode/aybolit.git custom-branch:gh-pages
/home/project/node_modules/@storybook/storybook-deployer/src/utils.js:14
  throw new Error(
  ^
Error: Exec code(1) on executing: git push --force --quiet [email protected]:dominik-stypula-polcode/aybolit.git custom-branch:gh-pages
error: src refspec custom-branch does not match any
error: failed to push some refs to '[email protected]:dominik-stypula-polcode/aybolit.git'
    at Object.exec (/home/project/node_modules/@storybook/storybook-deployer/src/utils.js:14:9)
    at Object.<anonymous> (/home/project/node_modules/@storybook/storybook-deployer/bin/storybook_to_ghpages:69:14)
    at Module._compile (internal/modules/cjs/loader.js:1158:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
    at Module.load (internal/modules/cjs/loader.js:1002:32)
    at Function.Module._load (internal/modules/cjs/loader.js:901:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
    at internal/main/run_main_module.js:18:47
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Steps to reproduce the behavior

make a following script in package.json, and run it

"deploy-test": "yarn --cwd packages/storybook storybook-to-ghpages --source-branch=custom-branch"

Expected behavior

The script should deploy local custom-branch code to remote gh-pages branch.

Fix proposal

In bin script storybook-to-ghpages before the following code:

publishUtils.exec('git add .');
publishUtils.exec(`git commit -m ${JSON.stringify(config.commitMessage)}`);

add following code which does the checkout to the SOURCE_BRANCH if argument exists:

if(args.SOURCE_BRANCH) {
  publishUtils.exec(`git checkout -b ${JSON.stringify(args.SOURCE_BRANCH)}`);
  console.log(`=> Deploying from source branch: ${JSON.stringify(args.SOURCE_BRANCH)}`);
}

Instructions For CircleCI

Leaving this here for anyone struggling to get Storybook + CircleCI to work.

1. Setup SSH keys

  1. Create a key per these instructions. Note that CircleCI requires the PEM format, so the command to generate a key is ssh-keygen -m PEM -t rsa -b 4096 -C "[email protected]"
  2. Add the public key to your project in Github https://github.com/{YOU}/{YOUR_PROJECT}/settings/keys
  3. Add the private key to your CircleCI project https://circleci.com/gh/{YOU}/{YOUR_PROJECT}/edit#ssh

2. Update CircleCI project settings

  1. Per this article, turn off "Pass secrets to builds from forked pull requests" in your project's Advanced Settings https://circleci.com/gh/{YOU}/{YOUR_PROJECT}/edit#advanced-settings

3. Update .circleci/config.yml

  1. Add new write-enabled ssh key to your job using the add_ssh_keys setting https://circleci.com/docs/2.0/add-ssh-key/
  2. Add branch filters to your workflow to prevent CircleCI from building when gh-pages gets committed to.

Here's my config for reference:

version: 2.1

executors:
  node:
    docker:
      - image: circleci/node:10.15.0

commands:
  install_dependencies:
    ...
  set_deploy_key:
    description: Sets the ssh key for project access
    steps:
      - add_ssh_keys:
          fingerprints:
            - 'YOUR FINGERPRINT HERE'

jobs:
  ...
    deploy:
      executor: node
      steps:
        - set_deploy_key
        - checkout
        - install_dependencies
        - run:
            name: Deploy
            command: yarn deploy

workflows:
  deploy:
    jobs:
      - lint:
          filters:
            branches:
              ignore: 'gh-pages'
      - test:
          filters:
            branches:
              ignore: 'gh-pages'
      - deploy:
          filters:
            branches:
              only: master
          requires:
            - lint
            - test

loading fonts and images from static folder

First of all, great tool. The entire storybook suite has made UI dev much, much faster.

Here's my issue: I have some static files (fonts and images) that I need to load in my stories. These work great locally. But, once deployed onto github pages (https://awei01.github.io/sui-stateless-components), <img src> references and css url() references stop working.

Specifically an <img src='/images/foo.png'> which worked locally now breaks because github pages appends the project name after my github pages url.

Specific links which illustrate this issue:

Is there a workaround for this issue?

Feature request: 404 that redirects to the index

It seems that the default deploy pushes to the gh-pages branch and that the deploy is successful; however, if go to mydomain.github.com/mylibrary I get a 404 but if I go to mydomain.github.com/mylibrary/index.html I get the storybook page.

So one method (i.e. hack) to get around this is to have a 404.html page that redirects to the index.html page. Perhaps this plugin could automatically deploy a 404 page if configured via a --fourOhFour 404.html cli argument.

If there's a more nuanced way to fix this, I'm all ears. :)

Can't get started

I am probably doing something very wrong..
I did this:

  1. I cloned the very simple demo
  2. npm i
  3. npm i --save @kadira/storybook-deployer
  4. Added "deploy-storybook": "storybook-to-ghpages"
  5. npm run deploy-storybook

And got the attached npm-debug.log
npm-debug.pdf

--source-branch=story-test fails

Have some problems with dynamic change of source branch.
Can anybody help me with that? Thanks in advance!

Error: Exec code(1) on executing: git push --force --quiet https://github.com/sOstrovsky/staticStoryBook.git story-test:gh-pages
undefined
    at Object.exec (/Users/***/WebstormProjects/Static StoryBook/node_modules/@storybook/storybook-deployer/src/utils.js:14:9)
    at Object.<anonymous> (/Users/***/WebstormProjects/Static StoryBook/node_modules/@storybook/storybook-deployer/bin/storybook_to_ghpages:69:14)
    at Module._compile (internal/modules/cjs/loader.js:816:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:827:10)
    at Module.load (internal/modules/cjs/loader.js:685:32)
    at Function.Module._load (internal/modules/cjs/loader.js:620:12)
    at Function.Module.runMain (internal/modules/cjs/loader.js:877:12)
    at internal/main/run_main_module.js:21:11
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] deploy-storybook: `storybook-to-ghpages "--source-branch=story-test"
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] deploy-storybook script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/***/.npm/_logs/2019-05-07T15_50_04_243Z-debug.log

Failure on Travis CI Exec code 134

Hi, I'm trying to get the deployer working on travis. Locally works fine.

Everything seems to be configured correctly, but during the build I'm getting the following error:

Error: Exec code(134) on executing: build-storybook  -o out6368
undefined
    at Object.exec (/home/travis/build/elastic/elastic-charts/node_modules/@storybook/storybook-deployer/src/utils.js:14:9)
    at buildStorybook (/home/travis/build/elastic/elastic-charts/node_modules/@storybook/storybook-deployer/src/build.js:18:18)
    at module.exports (/home/travis/build/elastic/elastic-charts/node_modules/@storybook/storybook-deployer/src/build.js:81:5)
    at Object.<anonymous> (/home/travis/build/elastic/elastic-charts/node_modules/@storybook/storybook-deployer/bin/storybook_to_ghpages:24:1)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Script failed with status 1

This is the failing build: https://travis-ci.org/elastic/elastic-charts/builds/489850823

GH_TOKEN is correctly configured (I'm using this for semantic-release) and the deployer is configured to use --ci args:

deploy:
  provider: script
  script: yarn storybook:deploy --ci
  skip_cleanup: true
  on:
    branch: master

release storybook to npm from GitLab

Hi,

I am using Gitlab to host my repository and I have followed the instructions step by step when it comes to creating a design system.

When I reach the stage where I have to publish to NPM, I am stuck. Because I am using Gitlab, they are not GitHub actions and can't use Auto. Somehow got the chromatic work without using Github actions but not successful when reaching the releasing part https://storybook.js.org/tutorials/design-systems-for-developers/react/en/distribute/

Through my project, I am using semantic release for versioning, this how my current yml file looks like:

include:
  - project: "XXXXXXXX"
    ref: master
    file:
      - yyyyyyyyy.yml

image: node:12

# Sets the stages for the pipeline
stages:
  - publish
  - tag

# Cache the dependencies
cache:
  key: $CI_COMMIT_REF_SLUG-$CI_PROJECT_DIR
  paths:
    - .yarn-cache
    - node_modules

.install-dependencies:
  before_script:
    - yarn install --frozen-lockfile --prefer-offline --cache-folder .yarn


publish:
  stage: publish
  rules:
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
      when: always
  script:
    - yarn install --frozen-lockfile --prefer-offline --cache-folder .yarn
    - yarn build-storybook  
    - npx chromatic  --storybook-build-dir ./storybook-static --project-token $CHROMATIC_PROJECT_TOKEN --exit-zero-on-changes


Release:
  stage: Release
  rules:
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
      when: always
  script:
    - yarn install --frozen-lockfile --prefer-offline --cache-folder .yarn
    - yarn build

any one can help, please?

Use gh-pages instead of own implementation

I propose to use the module gh-pages which has the complete deployment logic already implemented. This would replace the currently unstable and dirty implementation for the git actions which are needed to deploy to the branch gh-pages.

Example `package.json` for monorepo deployment

I'm trying to deploy storybook to another repo (using remote option) that has multiple storybooks. For monorepo option packages, I cannot find any example for package.json files inside packages folder. Anyone could point out?

--output .out mandatory?

So the README says this:

https://github.com/storybooks/storybook-deployer#custom-build-configuration

Custom Build Configuration
If you customize the build configuration with some additional params (like static file directory), then you need to expose another NPM script like this:
{
"scripts": {
...
"build-storybook": "build-storybook -s public -o .out",
...
}
}
Make sure to set the output directory as .out.

does this mean that you cannot use storybook-deployer to deploy a custom directory? my build storybook reads:

"build-storybook": "build-storybook --config-dir config/storybook --out public/",

in other words, i want to maintain my public/ directory as the source of truth for my compiled storybook artifacts. is it possible to have storybook-deployer use this script?

Don't rely on force push

Hey @arunoda

Our organization has strict requirements to not allow force pushing on any repositories, mostly because it generally isn't a good thing for us.

What are your thoughts on using a merge/rebase flow instead of force pushing?

Error when run yarn deploy-storybook --ci in CircleCi

Hey guys,

I'm having an error while trying to deploy with CircleCi.

I don't know what's happening, because the problem began to appear now, and before that, it was already working.

my config:

version: 2 # use CircleCI 2.0
jobs:
  build:
    docker:
      - image: circleci/node:9-stretch
    environment:
      TZ: "/usr/share/zoneinfo/America/Sao_Paulo"
    steps:
      - checkout # special step to check out source code to working directory
      - run: sudo apt-get update
      - run: sudo apt-get install apt-transport-https
      - run: curl -fsSL https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
      - run: echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
      - run: sudo apt-get update && sudo apt-get install yarn && yarn
      - save_cache: # special step to save the dependency cache
          key: dependency-cache-{{ checksum "package.json" }}
          paths:
            - ./node_modules
      - run:
          name: Run React Tests
          command: yarn jest --no-cache --runInBand

  deploy:
    docker:
      - image: circleci/node:12.2.0
    environment:
     GH_TOKEN: "MY_GH_TOKEN"
     NPM_TOKEN: "MY_NPM_TOKEN"
    steps:
      - checkout
      - run: sudo apt-get update
      - run: sudo apt-get install apt-transport-https
      - run: curl -fsSL https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
      - run: echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
      - run: sudo apt-get update && sudo apt-get install yarn && yarn
      - run:
          name: Deploy Storybook
          command: yarn deploy-storybook --ci

  release:
    docker:
      - image: circleci/node:9-stretch
    environment:
     GH_TOKEN: "MY_GH_TOKEN"
     NPM_TOKEN: "MY_NPM_TOKEN"
    steps:
      - checkout
      - run: sudo apt-get update
      - run: sudo apt-get install apt-transport-https
      - run: curl -fsSL https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
      - run: echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
      - run: sudo apt-get update && sudo apt-get install yarn && yarn
      # Run optional required steps before releasing
      # - run: npm run build-script
      - run: yarn semantic-release

workflows:
  version: 2
  test_and_release:
    jobs:
      - build
      - deploy:
          requires:
              - build
      - release:
          requires:
            - build

This is the error:
circleCi

Can someone help me?

Failed to exec deploy-storybook script

Describe the bug
No longer able to deploy to GH Pages after updating to react-scripts 4.0.1 Previously I was able to simply run npm run deploy-storybook. Now when running the deploy command it fails when building -storybook. It fails at 92% of build process on chunk asset optimization TerserPlugin.

To Reproduce
Using react-scripts 3.4.4 storybook build correctly
Updating to react-scripts 4.0.1 storybook build fails which also prevents deploying to gh pages

Expected behavior
Successfully builds and deploys updates to GH Pages

System
OS: macOS 10.15.6
CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz

Binaries:
Node: 12.12.0 - ~/.nvm/versions/node/v12.12.0/bin/node
npm: 6.11.3 - ~/.nvm/versions/node/v12.12.0/bin/npm

npmPackages:
@storybook/addon-actions: 6.1.21 => 6.1.21
@storybook/addon-essentials: 6.1.21 => 6.1.21
@storybook/addon-links: 6.1.21 => 6.1.21
@storybook/addons: 6.1.21 => 6.1.21
@storybook/node-logger: 6.1.21 => 6.1.21
@storybook/preset-create-react-app: 3.1.7 => 3.1.7
@storybook/react: 6.1.21 => 6.1.21
@storybook/storybook-deployer: 2.8.7 => 2.8.7
@storybook/theming: 6.1.21 => 6.1.21

Additional context
_lastActiveSortFn: undefined, ERR! _sortFn: undefined, ERR! _cache: undefined, ERR! _cacheOrderIndependent: undefined ERR! }, ERR! contextDependencies: SortableSet [Set] { ERR! '/Users/private-user/private-repo/src', ERR! _sortFn: undefined, ERR! _lastActiveSortFn: null, ERR! _cache: undefined, ERR! _cacheOrderIndependent: undefined ERR! }, ERR! missingDependencies: SortableSet [Set] { ERR! _sortFn: undefined, ERR! _lastActiveSortFn: null, ERR! _cache: undefined, ERR! _cacheOrderIndependent: undefined ERR! } ERR! }, ERR! hash: '82b3f88322128a30b9ea', ERR! startTime: 1616717641781, ERR! endTime: 1616717683706 ERR! }

[Bug] Running into CSP issues when deploying to gh pages

Describe the bug

We have a custom build structure -
"build-storybook": "build-storybook -s local-dir",

but when deploying we run into this error on our GitHub pages instance.
EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "script-src 'self' 'unsafe-inline'".

we've recently updated to storybook v 6 and have verified that the local instance of storybook is working perfectly.

Screenshots and/or logs

image

EACCES: permission denied

Commande to execute :
npm run deploy-storybook

In package.json :
"deploy-storybook": "storybook-to-aws-s3 --bucket-path=BUCKET/ --aws-profile=int"

I have this error:

+ npm run deploy-storybook

> [email protected] deploy-storybook /var/jenkins_home/jobs/JOB/branches/FEATURE/workspace@2
> storybook-to-aws-s3 --bucket-path=BUCKET/ --aws-profile=int

=> Building storybook for: PROJECT
   executing: npm run build-storybook -- -o out9154

/var/jenkins_home/jobs/JOB/branches/FEATURE/workspace@2/node_modules/@storybook/storybook-deployer/src/utils.js:14
  throw new Error(
  ^

Error: Exec code(1) on executing: npm run build-storybook -- -o out9154
info @storybook/react v6.1.1
info 

info => Cleaning outputDir /var/jenkins_home/jobs/JOB/branches/FEATURE/workspace@2/out9154
ERR! Error: EACCES: permission denied, mkdir '/usr/local/bin/docker/.Trash-1000'
ERR!  [Error: EACCES: permission denied, mkdir '/usr/local/bin/docker/.Trash-1000'] {
ERR!   errno: -13,
ERR!   code: 'EACCES',
ERR!   syscall: 'mkdir',
ERR!   path: '/usr/local/bin/docker/.Trash-1000'
ERR! }
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build-storybook: `build-storybook -s public "-o" "out9154"`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] build-storybook script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

I have Jenkins insalled from docker image (I insytall awscli and node)

FROM jenkinsci/blueocean
USER root
RUN apk add --no-cache \
        python3 \
        py3-pip \
    && pip3 install --upgrade pip \
    && pip3 install \
        awscli \
    && rm -rf /var/cache/apk/*

RUN apk add --update npm

USER jenkins

Hardcoded remote is too inflexible

At the moment the tool is hardcoded to look at remote.origin.url. This has caused issues where my fork of an organisation's repository is named originโ€”I've now got a page live under my username as opposed updating the organisation's page.

Now I can go and rename my remote, so this isn't the case, but I think it's a fairly common scenario to be in. What would be great is if the remote could be supplied as an argument to the CLI, e.g.,

storybook-to-ghpages --remote origin

Config to allow deploying existing build folders

My team would like to build our storybook assets at a separate step in the CI flow, and the deploy it at the very end. Ideally we should be able to specify an existing-output-dir that storybook should read from instead of building its own static assets.

Deployed Github pages URL has an extra column

Minor issue spotted on the output of the command when deploying to github pages:

=> Storybook deployed to: https://:myusername.github.io/my-repo/
โœจ  Done in 53.60s.

There is an extra column https:// : myusername[...].
That crashes the convenient Ctrl+click in terminal window to open a URL in browser.

Error thrown running `storybook-to-ghpages` as a Github Action

I'm running the following npm script from a Github Action:
"deploy-storybook": "storybook-to-ghpages -p packages -o=storybook-static --ci"

When npm run deploy-storybook is executed locally, it runs successfully.

When run as part of my Github Action, it fails with a generic error message. Running build-storybook from CI has no issue.

Step:

      - name: Deploy to GH Pages
        env:
          GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
        run: npm run deploy-storybook

Error from Logs:

=> Deploying storybook
   executing: git push --force --quiet https://***@github.com/org/repo master:gh-pages
/home/runner/work/petra/petra/node_modules/@storybook/storybook-deployer/src/utils.js:14
  throw new Error(
  ^

Error: Exec code(128) on executing: git push --force --quiet https://***@github.com/org/repo master:gh-pages
undefined
    at Object.exec (/home/runner/work/petra/petra/node_modules/@storybook/storybook-deployer/src/utils.js:14:9)
    at Object.<anonymous> (/home/runner/work/petra/petra/node_modules/@storybook/storybook-deployer/bin/storybook_to_ghpages:69:14)
    at Module._compile (internal/modules/cjs/loader.js:955:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10)
    at Module.load (internal/modules/cjs/loader.js:811:32)
    at Function.Module._load (internal/modules/cjs/loader.js:723:14)
    at Function.Module.runMain (internal/modules/cjs/loader.js:1043:10)
    at internal/main/run_main_module.js:17:11
npm ERR! code ELIFECYCLE
npm ERR! errno 1

Invalid deployment URL for ssh remotes

When using an ssh remote URL it seems to produce invalid GitHub pages link:

=> Deploying storybook
   executing: git push --force --quiet [email protected]:feimosi/my-repo.git master:gh-pages

=> Storybook deployed to: https://git.github.io/my-repo/

Should be of course: https://feimosi.github.io/my-repo/

I've tried to trace the issue down the dependency tree:
https://github.com/IonicaBizau/git-url-parse
โ†“
https://github.com/IonicaBizau/git-up
โ†“
https://github.com/pillarjs/parseurl
and seems like the underlying node-url package doesn't support this type of an URL. You'd probably have to handle this case here or report it to git-up package.

Deployment to Github Enterprise Pages -- Anyone done this?

Hello everyone.

I just learned about the storybook deployer for Github pages and was wondering if anyone has gotten this to work with Github Enterprise. I have gotten the deployment to work and the ghpages branch was created on my repository. The settings for the repository also point to that branch for the Pages part. I have waited over an hour and I am still seeing a 404 error.

Any thoughts on other bits that need to be set to get this to work properly?

Thanks,

Shane

[Question] Deploying to another repo.

Hi,

I have a question about the storybook-deployer. Currently I am having a setup where my codebase, storybook stories are in one repo (for e.g foo), but I want to be able to deploy the generated static site to another repo (for e.g. foo-storybook) ?

The reason for this is, when I used the storybook-deployer with the default configuration, I was able to push the static site to the gh-page branch of my main repo successfully however I noticed two things

  1. My entire code base code gets wiped out and the gh-pages branch only has the generated site
  2. I believe storybook-deployer did a git push --force into the gh-pages` branch.

I want to avoid these two steps on my main repo and keep the main code and the storybook site separate.

Please let me know if there is a way to achieve this. Thanks for you time.

Nikhilesh

support for Storybook deployer for git Lab pages

Is there a storybook deployer support for GitLab Pages (not for Git Hub pages)?
I need to understand how to manually integrate storybook serverless deployment onto Gitlab Pages. I read all the documentation and could not find a support doc for GitLab (found it for GitHub and AWS)

SyntaxError: Unexpected token ...

Use storybook + typescript. I do not have .babelrc with babel-plugin-transform-object-rest-spread.
I execute the command storybook-to-ghpages -- --existing-output-dir=.out getting an error

npm run deploy-storybook

> [email protected] deploy-storybook /var/www/components_ui
> storybook-to-ghpages -- --existing-output-dir=.out --dry-run

/var/www/components_ui/node_modules/@storybook/storybook-deployer/bin/storybook_to_ghpages:11
const { config, ...args } = parseArgs(packageJson);
                ^^^

SyntaxError: Unexpected token ...
    at createScript (vm.js:74:10)
    at Object.runInThisContext (vm.js:116:10)
    at Module._compile (module.js:533:28)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:503:32)
    at tryModuleLoad (module.js:466:12)
    at Function.Module._load (module.js:458:3)
    at Function.Module.runMain (module.js:605:10)
    at startup (bootstrap_node.js:158:16)
    at bootstrap_node.js:575:3

Use folder other than .storybook

Currently, it's not possible to use storybook-deployer with config folder other than .storybook. It would be nice to have a -c path/to/storybook like in start-storybook

Deploy custom branch

Accept a parameter to indicating which branch to deploy from. Currently it is hardcoded to master.

Works locally but I get an error on Travis

I'd love to have my storybook deploy auto but I keep hitting this 128 error

storybook-to-ghpages
=> Getting the git remote URL
executing: git config --get remote.origin.url
=> Building storybook
executing: npm run build-storybook -- -o out7256
executing: git init
executing: git config user.name "GH Pages Bot"
executing: git config user.email "[email protected]"
executing: git config commit.gpgsign false
executing: git add .
executing: git commit -m "Deploy Storybook to GitHub Pages"
=> Deploying storybook
executing: git push --force --quiet https://github.com/Holochain/web-components.git master:gh-pages
/home/travis/build/Holochain/web-components/node_modules/@storybook/storybook-deployer/src/utils.js:16
throw new Error(message);
^
Error: Exec code(128) on executing: git push --force --quiet https://github.com/Holochain/web-components.git master:gh-pages
undefined
at Object.exec (/home/travis/build/Holochain/web-components/node_modules/@storybook/storybook-deployer/src/utils.js:16:9)
at Object. (/home/travis/build/Holochain/web-components/node_modules/@storybook/storybook-deployer/bin/storybook_to_ghpages:68:14)
at Module._compile (module.js:635:30)
at Object.Module._extensions..js (module.js:646:10)
at Module.load (module.js:554:32)
at tryModuleLoad (module.js:497:12)
at Function.Module._load (module.js:489:3)
at Function.Module.runMain (module.js:676:10)
at startup (bootstrap_node.js:187:16)
at bootstrap_node.js:608:3

[Bug] Error running yarn deploy-storybook to s3 in github action

Describe the bug

Hi there, I'm trying to automate the deploy of my storybook to S3, and, while it works locally, it's failing in the Github Action.

Steps to reproduce the behavior

My current command for deploy-storybook:

"deploy-storybook": "storybook-to-aws-s3 --ci --bucket-path=<my-bucket> --s3-sync-options='--delete'"

This is the my current action:

name: Storybook to S3

on:
  push:
    branches:
      - '*'

env:
  CI: true

jobs:
  Storybook:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: borales/[email protected]
        with:
          cmd: install
      - name: Configure AWS Credentials
        uses: aws-actions/configure-aws-credentials@v1
        with:
          aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
          aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
          aws-region: us-east-1
      - name: Deploy storybook
        uses: borales/[email protected]
        with:
          cmd: deploy-storybook

It fails with the following:

$ storybook-to-aws-s3 --ci --bucket-path=<my-bucket> --s3-sync-options='--delete'
=> Building storybook for: ui
   executing: npm run build-storybook -- -o out8987
=> Deploying storybook
   executing: aws --profile default s3 sync out8987 s3://<my-bucket>/ --delete
/github/workspace/node_modules/@storybook/storybook-deployer/src/utils.js:14
  throw new Error(
  ^

Error: Exec code(127) on executing: aws --profile default s3 sync out8987 s3://<my-bucket>/ --delete
/bin/sh: aws: not found

    at Object.exec (/github/workspace/node_modules/@storybook/storybook-deployer/src/utils.js:14:9)
    at Object.<anonymous> (/github/workspace/node_modules/@storybook/storybook-deployer/bin/storybook_to_aws_s3:37:14)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
    at internal/main/run_main_module.js:17:47
error Command failed with exit code 1.

I've checked that aws is installed and within the PATH of the runner:

which aws = /usr/local/bin/aws
echo $PATH = /home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin:/opt/pipx_bin:/usr/share/rust/.cargo/bin:/home/runner/.config/composer/vendor/bin:/home/runner/.dotnet/tools:/snap/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin

Expected behavior

I expected the action to be able to find the AWS binary.

Has anyone been able to run this within a github action? I tried to run npm run (even though the package was setup with yarn) and it gave me some really shady errors as well.

Any help/guidance would be much appreciated :)

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.