Skip to content
This repository has been archived by the owner on Jan 16, 2023. It is now read-only.

The --source-branch Flag Throws Error #86

Closed
stephenhmarsh opened this issue Jun 29, 2020 · 2 comments · Fixed by #87
Closed

The --source-branch Flag Throws Error #86

stephenhmarsh opened this issue Jun 29, 2020 · 2 comments · Fixed by #87

Comments

@stephenhmarsh
Copy link
Contributor

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 

> marble@0.1.0 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 "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 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! marble@0.1.0 deploy-storybook: `storybook-to-ghpages "--source-branch=main"`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the marble@0.1.0 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 npm@6.14.5
3 info using node@v12.14.1
4 verbose run-script [ 'predeploy-storybook', 'deploy-storybook', 'postdeploy-storybook' ]
5 info lifecycle marble@0.1.0~predeploy-storybook: marble@0.1.0
6 info lifecycle marble@0.1.0~deploy-storybook: marble@0.1.0
7 verbose lifecycle marble@0.1.0~deploy-storybook: unsafe-perm in lifecycle true
8 verbose lifecycle marble@0.1.0~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 marble@0.1.0~deploy-storybook: CWD: /Users/stephen/dev/Marble
10 silly lifecycle marble@0.1.0~deploy-storybook: Args: [ '-c', 'storybook-to-ghpages "--source-branch=main"' ]
11 silly lifecycle marble@0.1.0~deploy-storybook: Returned: code: 1  signal: null
12 info lifecycle marble@0.1.0~deploy-storybook: Failed to exec deploy-storybook script
13 verbose stack Error: marble@0.1.0 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 marble@0.1.0
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 marble@0.1.0 deploy-storybook: `storybook-to-ghpages "--source-branch=main"`
22 error Exit status 1
23 error Failed at the marble@0.1.0 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       
> marble@0.1.0 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 "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 https://github.com/metmuseum/Marble.git master:gh-pages
=> Storybook deployed to: https://metmuseum.github.io/Marble/
@2metres
Copy link

2metres commented Jul 17, 2020

Any progress on this fix?

I am also seeing this issue since changing our branch naming conventions.

@stephenhmarsh
Copy link
Contributor Author

stephenhmarsh commented Jul 17, 2020

@2metres They haven't responded, I think this project isn't maintained anymore? But check my comment on #87 -- I realized that --source-branch doesn't really do anything. The docs are misleading or out of date. Basically, storybook deployer makes a new throwaway repo every time you run it. While my fix does make --source-branch "work," it's just kind of pointlessly setting a branch name that doesn't matter, it all starts from a blank repo, gets your storybook built on it, then ends up on --branch (gh-pages if not specified), then gets cleaned up. So, in other words, it doesn't point to like, main of your project, and you don't need to set it to build from main, you just need to run the script from the branch you want to build from (ie, git checkout main...). Hope that helps.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging a pull request may close this issue.

2 participants