New orb: leanpub

Hi,

I’m not sure if it’s good etiquette to post announcements for new orbs here (please let me know if this is the case). I wrote a new orb for automating Leanpub API operations, to automate my book preview/publishing workflow. Thought others who use Leanpub might find it useful.

Orb: https://circleci.com/orbs/registry/orb/zzamboni/leanpub
Orb source (it’s my first orb, feedback appreciated!): https://github.com/zzamboni/leanpub-orb
Blog post describing how I use it: https://zzamboni.org/post/automating-leanpub-book-publishing-with-hammerspoon-and-circleci/

2 Likes

@zzamboni Definitely, that’s a great use of the Orbs channel here, so thanks!

@tomtrahan Any interest in reaching out to Leanpub—maybe they’d be interested in adopting @zzamboni’s work so it can become an official partner orb?

@zzamboni I can offer some fuller feedback later, but glancing over this orb quickly, one thing that stands out—

Anywhere you have a parameter whose default value is an environment variable (e.g, $LEANPUB_API_KEY), I would strongly encourage you to change that parameter’s type to env_var_name:

https://circleci.com/docs/2.0/reusing-config/#environment-variable-name

That way, it’s 100% explicit to users that they should not pass sensitive data like API keys, etc., to the orb as string literals.

But generally, the orb looks very full-featured, and I appreciate the usage example, as well—great work! @zzamboni

2 Likes

Hi @zzamboni - This is really interesting and unique. Great work! I think your orb covers the use case well, so I’m not planning to reach out to Leanpub separately.

1 Like

@rose, @tomtrahan - thanks for the kind words! I have been invited to appear in an upcoming episode of Leanpub’s Frontmatter author podcast, so I might mention this there as well. I’ll post an update here if/when this happens.

@rose: thanks for the feedback about the env_var_name parameters. I have updated my orb to use it. I have one question: is it possible to specify that an env var parameter must be specified (i.e. that the corresponding environment variable must be defined)? At the moment I had to insert check code to make sure the job fails when the variable is not defined, like this: https://github.com/zzamboni/leanpub-orb/blob/master/src/%40orb.yml#L87-L90

Thanks again for the feedback and the encouragement - I look forward to any other comments you may have.

2 Likes

@zzamboni No, what you’re doing there is great. It’s not that much boilerplate, but still, it’s a common-enough situation that we could probably abstract that logic into its own orb command. Something like check-env-var-param. It would probably be a great fit for our Orb Tools orb:

@rose thanks for the idea - it works great. I have implemented the check-env-var-param command in my orb for now - I would be happy to submit a PR for the orb-tools orb with this command as well. Please let me know if you have any feedback: https://github.com/zzamboni/leanpub-orb/blob/master/src/commands/check-env-var-param.yml

@rose I’ve submitted a PR for orb-tools with the check-env-var-param command. Feedback much appreciated: https://github.com/CircleCI-Public/orb-tools-orb/pull/27

1 Like

@zzamboni Amazing, thanks so much! Taking a look now.

Now if only we had top-level parameters, and a list type parameter—then we could use this to easily/automatically check all of an orb job/command’s defined env_var_name parameters…

Awesome - thanks for merging it! I have updated my orb to use the new version of orb-tools and removed the local definition of the command :slight_smile: