Giter Club home page Giter Club logo

read-action's Introduction

read-action

Test Read

This GitHub action tracks the books that you read by updating a JSON file in your repository. Pair it with the iOS Shortcut to automatically trigger the action or click Run workflow from the Actions tab to submit details about the book.

Create a workflow dispatch event with information about the book. The action will then fetch the book's metadata using node-isbn and commit the change in your repository, always sorting by the date you finished the book.

Book lifecycle

When you add or update a book, you can set it as: want to read, started, finished, or abandoned. This will set the value as bookStatus and will add an accompanying date for the status.

Set up the workflow

To use this action, create a new workflow in .github/workflows and modify it as needed:

name: read action
run-name: 📚 ${{ inputs['book-status'] }} book ${{ inputs.isbn }}

# Grant the action permission to write to the repository
permissions:
  contents: write

# Trigger the action
on:
  workflow_dispatch:
    inputs:
      isbn:
        description: The book's ISBN. Required.
        required: true
        type: string
      book-status:
        description: What is the status of the book? Required.
        required: true
        type: choice
        default: "want to read"
        options:
          - "want to read"
          - "started"
          - "finished"
          - "abandoned"
      date:
        description: Date to record the status of the book (YYYY-MM-DD). Leave blank for today. Optional.
        type: string
      notes:
        description: Notes about the book. Optional.
        type: string
      # Adding a rating is optional.
      # You can change the options to whatever you want to use.
      # For example, you can use numbers, other emoji, or words.
      rating:
        description: Rate the book. Optional.
        type: choice
        default: "unrated"
        options:
          - "unrated"
          - ⭐️
          - ⭐️⭐️
          - ⭐️⭐️⭐️
          - ⭐️⭐️⭐️⭐️
          - ⭐️⭐️⭐️⭐️⭐️
      # Tags are optional.
      tags:
        description: Add tags to categorize the book. Separate each tag with a comma. Optional.
        type: string

# Set up the steps to run the action
jobs:
  update-library:
    runs-on: macOS-latest
    name: Read
    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Read
        uses: katydecorah/[email protected]

      - name: Commit updated read file
        run: |
          git pull
          git config --local user.email "[email protected]"
          git config --local user.name "GitHub Action"
          git add -A && git commit -m "📚 “${{ env.BookTitle }}” (${{ env.BookStatus }})"
          git push

Additional example workflows

When book is missing metadata, create a pull request
name: When book is missing metadata, create a pull request
run-name: 📚 ${{ inputs['book-status'] }} book ${{ inputs.isbn }}

# Grant the action permission to write to the repository
permissions:
  contents: write
  pull-requests: write

# Trigger the action
on:
  workflow_dispatch:
    inputs:
      book-status:
        description: What is the status of the book? Required.
        required: true
        type: choice
        default: "want to read"
        options:
          - "want to read"
          - "started"
          - "finished"
          - "abandoned"
      date:
        description: Date to record the status of the book (YYYY-MM-DD). Leave blank for today. Optional.
        type: string
      isbn:
        description: The book's ISBN. Required.
        required: true
        type: string
      notes:
        description: Notes about the book. Optional.
        type: string
      # Adding a rating is optional.
      # You can change the options to whatever you want to use.
      # For example, you can use numbers, other emoji, or words.
      rating:
        description: Rate the book. Optional.
        type: choice
        default: "unrated"
        options:
          - "unrated"
          - ⭐️
          - ⭐️⭐️
          - ⭐️⭐️⭐️
          - ⭐️⭐️⭐️⭐️
          - ⭐️⭐️⭐️⭐️⭐️
      # Tags are optional.
      tags:
        description: Add tags to categorize the book. Separate each tag with a comma. Optional.
        type: string

# Set up the steps to run the action
jobs:
  update-library:
    runs-on: macOS-latest
    name: Read
    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Read
        id: read_action
        with:
          set-image: true
        uses: katydecorah/[email protected]

      - name: Download the book thumbnail
        if: env.BookThumbOutput != ''
        run: curl "${{ env.BookThumb }}" -o "img/${{ env.BookThumbOutput }}"

      - name: Commit updated read file
        if: env.BookNeedsReview != 'true' # Do not commit book if it needs review
        run: |
          git pull
          git config --local user.email "[email protected]"
          git config --local user.name "GitHub Action"
          git add -A && git commit -m "📚 “${{ env.BookTitle }}” (${{ env.BookStatus }})"
          git push

      # Create pull request instead of directly committing if book is missing metadata
      # Occasionally, some books returned from node-isbn may be missing a few properties.
      # Add this step to your workflow if you want the ability to fix the missing data by making the action open a new pull request.
      # You can customize the properties that will trigger a pull request with the `required-metadata` input.
      - name: If book needs review, create a pull request to review book metadata
        if: env.BookNeedsReview == 'true'
        run: |
          git config pull.rebase true
          git fetch origin
          git config --local user.email "[email protected]"
          git config --local user.name "GitHub Action"
          git checkout -b review-book-${{env.BookIsbn}}
          git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
          git add -A && git commit -m "📚 “${{ env.BookTitle }}” (${{ env.BookStatus }})" -m "“${{ env.BookTitle }}” is missing the following properties: ${{env.BookMissingMetadata}}. Edit this pull request to add them or merge it in."
          git push --set-upstream origin review-book-${{env.BookIsbn}}
          gh pr create -B main -H "review-book-${{env.BookIsbn}}" --fill
        env:
          GH_TOKEN: ${{ github.token }}

      - name: Now reading
        if: steps.read_action.outputs.nowReading != ''
        run: |
          echo "Now reading: ${{ steps.read_action.outputs.nowReading }}"
Download the book thumbnail
name: Download the book thumbnail
run-name: 📚 ${{ inputs['book-status'] }} book ${{ inputs.isbn }}

# Grant the action permission to write to the repository
permissions:
  contents: write

# Trigger the action
on:
  workflow_dispatch:
    inputs:
      isbn:
        description: The book's ISBN. Required.
        required: true
        type: string
      book-status:
        description: What is the status of the book? Required.
        required: true
        type: choice
        default: "want to read"
        options:
          - "want to read"
          - "started"
          - "finished"
          - "abandoned"
      date:
        description: Date to record the status of the book (YYYY-MM-DD). Leave blank for today. Optional.
        type: string
      notes:
        description: Notes about the book. Optional.
        type: string
      # Adding a rating is optional.
      # You can change the options to whatever you want to use.
      # For example, you can use numbers, other emoji, or words.
      rating:
        description: Rate the book. Optional.
        type: choice
        default: "unrated"
        options:
          - "unrated"
          - ⭐️
          - ⭐️⭐️
          - ⭐️⭐️⭐️
          - ⭐️⭐️⭐️⭐️
          - ⭐️⭐️⭐️⭐️⭐️
      # Tags are optional.
      tags:
        description: Add tags to categorize the book. Separate each tag with a comma. Optional.
        type: string

# Set up the steps to run the action
jobs:
  update-library:
    runs-on: macOS-latest
    name: Read
    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Read
        uses: katydecorah/[email protected]
        with:
          thumbnail-width: 1280
          set-image: true

      - name: Download the book thumbnail
        if: env.BookThumbOutput != ''
        run: curl "${{ env.BookThumb }}" -o "img/${{ env.BookThumbOutput }}"

      - name: Commit updated read file
        run: |
          git pull
          git config --local user.email "[email protected]"
          git config --local user.name "GitHub Action"
          git add -A && git commit -m "📚 “${{ env.BookTitle }}” (${{ env.BookStatus }})"
          git push

Action options

  • filename: The file where you want to save your books. Default: _data/read.json.

  • providers: Specify the ISBN providers that you want to use, in the order you need them to be invoked. If setting more than one provider, separate each with a comma.

  • time-zone: Your time zone. Default: America/New_York.

  • required-metadata: Required metadata properties. This can be used to make the action open a pull request if one of these values is missing data in the desired book instead of committing directly to a repository. Default: title,pageCount,authors,description,thumbnail.

  • set-image: If true, the action will set the image for the book. This is helpful if you add an extra step to download this image.

  • thumbnail-width: The width of the thumbnail image (for books sourced from Google Books). The default size is 128.

Trigger the action

To trigger the action, create a workflow dispatch event with the following body parameters:

{
  "ref": "main", // Required. The git reference for the workflow, a branch or tag name.
  "inputs": {
    "isbn": "", // Required. The book's ISBN. Required.
    "book-status": "", // Required. What is the status of the book? Required. Default: `want to read`.
    "date": "", // Date to record the status of the book (YYYY-MM-DD). Leave blank for today. Optional.
    "notes": "", // Notes about the book. Optional.
    "rating": "", // Rate the book. Optional. Default: `unrated`.
    "tags": "", // Add tags to categorize the book. Separate each tag with a comma. Optional.
  }
}

Action outputs

  • nowReading: When a new book is started this output will contain an object with the book's: title, description, thumbnail, authors, and isbn.

read-action's People

Contributors

actions-user avatar dependabot[bot] avatar github-actions[bot] avatar katydecorah avatar taylor1791 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

read-action's Issues

Add support for larger versions of book cover images

Is your feature request related to a problem? Please describe.
The cover image thumbnails are too small for how my website displays images.

Describe the solution you'd like
I would like a new option in the workflow/action that can be enabled to download a high res version of the book cover. This way, I can use a plugin when generating my website to create different-sized versions of the cover to use as needed.

Describe alternatives you've considered
I'm considering curating my versions of the book covers and committing them to my repo. (I'm still not a fan of the media available in Google Books anyway :P )

Additional context
n/a

Store downloaded image in read.json

Is your feature request related to a problem? Please describe.
I'm trying to use eleventy-img to optimise the downloaded book covers on my bookshelf page.

I'm currently displaying the book covers without optimisation with a simple <img> tag with https://raw.githubusercontent.com/flamedfury/metadata-library/main/img/book-{{ book.isbn }}.png as the URL structure.

I cannot use this URL structure with eleventy-image; I can use it with something like {{ book.image }}.

The thumbnail URL is also not able to be used "thumbnail": "https://books.google.com/books/content?id=NCSYZ41UBaYC&printsec=frontcover&img=1&zoom=1&source=gbs_api&w=1280",.

Describe the solution you'd like
I would like URL to the downloaded bookcover, e.g. `` to be injected into the JSON file so I can render it with a simple Nunjuck tag {{ book.image }}.

Additional context
I have no idea whether this is possible

Kindle Book Support

Is your feature request related to a problem? Please describe.
Books published as Kindle or Audible do not appear in the Google Books search.

While we wait for the Overdrive audiobook support, I'm happy to log the books I finish as ebook versions for the sake of remembering.

I ran into this problem with The Renegade and The Deal. (Sorry for the Amazon links).

Generally, I've found Google Books to be pretty poor, with too many versions and poor cover support...

Describe the solution you'd like
Are there better ISBN APIs that could be used? Goodreads seems like the best resource for this type of thing.

Additional context
I'm just thinking aloud here.

Cannot read properties of undefined (reading 'startsWith')

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Go to https://github.com/flamedfury/metadata-library/actions/runs/3983544077/jobs/6828982134
  2. Click on Read
  3. See error Error: Cannot read properties of undefined (reading 'startsWith')

Expected behavior
A clear and concise description of what you expected to happen.

I expected to the action to complete successfully.

Screenshots
If applicable, add screenshots to help explain your problem.

image

Desktop (please complete the following information):

  • OS: [Pop!_OS 22.04 LTS]
  • Browser [Firefox]
  • Version [108.0.2 (64-bit)]

Additional context
Add any other context about the problem here.

This has happened with number of books, I have worked around by clicking on a different edition and running the action again with a different ISBN.

For this book, this is the only edition, so am unable to enter a new ISBN.

Audiobook Support

Is your feature request related to a problem? Please describe.
When I first set up the action, I listened to a series of Audio Books with no physical/ebook release. This failed the action as they did not exist on the Google Books database. I understand that this is at the mercy of node-isbn, but interested in whether there is a way to extend capability beyond node-isbn. One problem I see already is an audio-only book does not have a page count. For other audiobooks that also have physical/ebook releases this shouldn't be a problem.

Describe the solution you'd like
I want to be able to add audiobooks or audiobook versions to the data file.

Describe alternatives you've considered
Like you, I'm borrowing a lot of audiobooks from my local library through Libby/Overdrive. I wonder if they offer API access or whether this can be achieved by another resource like libro.fm.

Additional context
No additional context; I'd like to know if this is possible.

401 Error when running action

Hi, I have recently stumbled upon your homepage and have loved what you have done with your metadata library.

I've sat down tonight to set this up for myself based on your actions.

I've started with the read-action and have run into an error when running the action.

Run katydecorah/[email protected]
  with:
    timeZone: Pacific/Auckland
    readFileName: _data/read.json
  
Error: Request failed with status code 401

It's unclear to me what is causing the 401. Would you happen to have any idea?

The New Status's

Hey Katy,

I love the nowReading status and explanation of how to use it.

I've got some great ideas for revamping my bookshelf page on my website now.

One new feature that I thought would be great would be an abandoned status for books we've started but decided not to finish. It could take a "date abandoned" parameter.

Let me know what you think.

~fLaMEd

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.