Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't change publishing branch #11

Closed
alebianco opened this issue Mar 6, 2019 · 7 comments
Closed

Can't change publishing branch #11

alebianco opened this issue Mar 6, 2019 · 7 comments

Comments

@alebianco
Copy link
Contributor

Can't configure the branch where to publish the site content. This is needed in order to publish user or organisation pages.

The option is being stripped when resolving the configuration in attempt to ignore semantic-release's own branch value. Introduced by v1.1.1 because of #5

https://github.com/qiwi/semantic-release-gh-pages-plugin/blob/master/src/main/config.ts#L59

Probably the best course of action would be to change parameter name.

@antongolub
Copy link
Member

Sad but true.

// If `extends` is defined, load and merge each shareable config with `options`

For now, you're still able to define branch opt as a part of step-specific plugin config:

// ...
publish: [
  // ...
  ['@qiwi/semantic-release-gh-pages-plugin', {branch: 'gh-pages'}]
]

I need to take a closer look at the sem-rel config resolver.

@antongolub antongolub pinned this issue Mar 6, 2019
@alebianco
Copy link
Contributor Author

thanks for the suggestion but even with that, it always publish to gh-pages. I need to be able to publish to master or to any other branch really

@antongolub
Copy link
Member

antongolub commented Mar 7, 2019

@pvdlg, could you help us with this issue?
Looks like context.options.publish in its [{path: 'thisPlugin', decraredOpts}, ...]does not contain branch option, but respects other. I did a couple of experiments: #1, #2

The first proves that branch option was omitted, the second shows that msg option was passed as expected.

Config resolver:

export const resolveOptions = (pluginConfig: TAnyMap, context: TContext, path = PLUGIN_PATH, step?: string): TAnyMap => {
  const { options } = context
  const base = pluginConfig[path] || {}
  const extra = step && options[step] && castArray(options[step])
    .find(config => get(config, 'path') === path) || {}

  return { ...base, ...extra }
}

export const resolveConfig = (pluginConfig: TAnyMap, context: TContext, path = PLUGIN_PATH, step?: string): IGhpagesPluginConfig => {
  const { env } = context
  const opts = resolveOptions(pluginConfig, context, path, step)
  const token = getToken(env)
  const repo = getRepo(context)

  return {
    src: opts.src || DEFAULT_SRC,
    dst: opts.dst || DEFAULT_DST,
    msg: opts.msg || DEFAULT_MSG,
    branch: opts.branch || DEFAULT_BRANCH,
    token,
    repo
  }
}

@antongolub
Copy link
Member

@alebianco , finally I got it:

"publish": [
      "@semantic-release/npm",
      "@semantic-release/github",
      {
        "path": "@qiwi/semantic-release-gh-pages-plugin",
        "msg": "updated",
        "branch": "docs"
      }
    ]

@alebianco
Copy link
Contributor Author

I'm not 100% sure how but this workaround seems to work, thank you

@antongolub antongolub unpinned this issue Apr 1, 2019
@iamogbz
Copy link

iamogbz commented Jul 12, 2023

@antongolub running into this right now, there might have been a regression? Or maybe something changed on semantic release side.

Either way I have tried a bunch of different valid configurations and it still always pushes to gh-pages

publish: [
  // ...
  ['@qiwi/semantic-release-gh-pages-plugin', {branch: 'releaseBranch'}]
]
plugins: [
  // ...
  {path: '@qiwi/semantic-release-gh-pages-plugin', branch: 'releaseBranch'}]
]

@antongolub
Copy link
Member

antongolub commented Jul 13, 2023

Hey, @iamogbz,

What does debug print if enabled?

debug('pluginConfig= %j', pluginConfig)

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

No branches or pull requests

3 participants