storybook-eol / storybook-deployer

Deploy your storybook as a static site
MIT License
893 stars 71 forks source link

[Bug] custom SOURCE branch option doesn't work #101

Open dominik-stypula-polcode opened 3 years ago

dominik-stypula-polcode commented 3 years ago

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 "hello@ghbot.com"
   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 git@github.com: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 git@github.com: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 'git@github.com: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)}`);
}
dominik-stypula-polcode commented 3 years ago

anyone here?

noslouch commented 3 years ago

bump