Skip to content

lykinsbd/leanpub-multi-action

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

Leanpub Multi Action

CI

A GitHub Action to interact with the Leanpub API. Preview, publish, and check job status for your Leanpub books — directly from your GitHub workflows.

Quick Start

- name: "Preview Book"
  uses: "lykinsbd/leanpub-multi-action@v2"
  with:
    leanpub-api-key: "${{ secrets.LEANPUB_API_KEY }}"
    leanpub-book-slug: "mygreatbook"
    action: "preview"

Inputs

Name Required Default Description
leanpub-api-key Yes Leanpub API key (requires a Pro plan). Store as a GitHub Secret.
leanpub-book-slug Yes Book slug — the path component after https://leanpub.com/.
action Yes Action to perform: preview, publish, unpublish, check-status, book-summary, or book-exists.
email-readers No "false" Email readers about a new publish. Only used with publish.
release-notes No Release notes for the publish. Only used with publish.
subset No "false" Preview only the files listed in Subset.txt. Only used with preview.
single-file No Path to a Markdown file for single-file preview. Only used with preview.
wait No "false" Poll until job completes. Only used with check-status.
poll-interval No "5" Seconds between polls. Only used with check-status --wait.
timeout No "120" Max seconds to wait. Only used with check-status --wait.

Examples

Full preview on push

---
name: "Preview on Push"

"on":
  push:
    branches: ["preview"]

jobs:
  preview:
    runs-on: "ubuntu-latest"
    steps:
      - name: "Preview Book"
        uses: "lykinsbd/leanpub-multi-action@v2"
        with:
          leanpub-api-key: "${{ secrets.LEANPUB_API_KEY }}"
          leanpub-book-slug: "mygreatbook"
          action: "preview"

Subset preview

Preview only the files listed in your book's Subset.txt:

- name: "Subset Preview"
  uses: "lykinsbd/leanpub-multi-action@v2"
  with:
    leanpub-api-key: "${{ secrets.LEANPUB_API_KEY }}"
    leanpub-book-slug: "mygreatbook"
    action: "preview"
    subset: "true"

Single-file preview

Preview a single Markdown file without modifying Subset.txt. The output PDF is saved as {slug}-single-file.pdf in your Dropbox previews folder.

- name: "Checkout"
  uses: "actions/checkout@v4"
- name: "Single File Preview"
  uses: "lykinsbd/leanpub-multi-action@v2"
  with:
    leanpub-api-key: "${{ secrets.LEANPUB_API_KEY }}"
    leanpub-book-slug: "mygreatbook"
    action: "preview"
    single-file: "manuscript/chapter-05.md"

Publish with release notes

- name: "Publish"
  uses: "lykinsbd/leanpub-multi-action@v2"
  with:
    leanpub-api-key: "${{ secrets.LEANPUB_API_KEY }}"
    leanpub-book-slug: "mygreatbook"
    action: "publish"
    email-readers: "true"
    release-notes: "Chapter 5 added"

Unpublish

- name: "Unpublish"
  uses: "lykinsbd/leanpub-multi-action@v2"
  with:
    leanpub-api-key: "${{ secrets.LEANPUB_API_KEY }}"
    leanpub-book-slug: "mygreatbook"
    action: "unpublish"

Check job status

- name: "Check Status"
  uses: "lykinsbd/leanpub-multi-action@v2"
  with:
    leanpub-api-key: "${{ secrets.LEANPUB_API_KEY }}"
    leanpub-book-slug: "mygreatbook"
    action: "check-status"

Poll until job completes

- name: "Wait for Preview"
  uses: "lykinsbd/leanpub-multi-action@v2"
  with:
    leanpub-api-key: "${{ secrets.LEANPUB_API_KEY }}"
    leanpub-book-slug: "mygreatbook"
    action: "check-status"
    wait: "true"
    poll-interval: "10"
    timeout: "300"

Get book summary

Retrieve book metadata including download URLs, word count, and sales info:

- name: "Book Summary"
  uses: "lykinsbd/leanpub-multi-action@v2"
  with:
    leanpub-api-key: "${{ secrets.LEANPUB_API_KEY }}"
    leanpub-book-slug: "mygreatbook"
    action: "book-summary"

Check if book exists

- name: "Book Exists"
  uses: "lykinsbd/leanpub-multi-action@v2"
  with:
    leanpub-api-key: "${{ secrets.LEANPUB_API_KEY }}"
    leanpub-book-slug: "mygreatbook"
    action: "book-exists"

CLI Usage

The action also ships as a standalone CLI tool called lma.

uv tool install leanpub-multi-action

or with pip:

pip install leanpub-multi-action
lma --leanpub-api-key YOUR_KEY --book-slug mygreatbook preview
lma --leanpub-api-key YOUR_KEY --book-slug mygreatbook preview --subset
lma --leanpub-api-key YOUR_KEY --book-slug mygreatbook preview --single-file chapter.md
lma --leanpub-api-key YOUR_KEY --book-slug mygreatbook publish --email-readers --release-notes "v2"
lma --leanpub-api-key YOUR_KEY --book-slug mygreatbook unpublish
lma --leanpub-api-key YOUR_KEY --book-slug mygreatbook check-status
lma --leanpub-api-key YOUR_KEY --book-slug mygreatbook check-status --wait --timeout 300
lma --leanpub-api-key YOUR_KEY --book-slug mygreatbook book-summary
lma --leanpub-api-key YOUR_KEY --book-slug mygreatbook book-exists

Contributing

See CONTRIBUTING.md for development setup and guidelines.

License

Apache-2.0

About

Interact with Leanpub via GitHub Actions

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors