Track your books with GitHub Actions
I built read action, a GitHub Action, that tracks the books that you’ve read by storing the book metadata in a yaml file. Services like Goodreads exist, but I want to own my data.
How it works
After I finish a book, I create an issue in my site repository, enter the ISBN as the title, and add the read
label. Once I open the issue the GitHub action kicks off.
- The action parses the issue title to extract the ISBN.
- Then it uses node-isbn to return the metadata for the book. If I added any content to the body of the issue, the action will set it as the value of
notes
in the book entry. The action will also set thedateFinished
to today, unless I specify aYYYY-MM-DD
value in the title of the issue. - As a last step, the action fetches my repository’s library (
_data/read.yml
), adds the book entry, orders all entries bydateFinished
, and rewrites the file.
Finally, the workflow commits the changes and closes the issue.
Pair it with an iOS Shortcut
I created a Shortcut to help me automate issue creation from my iPhone.
When I click the Finished a book Shortcut, it asks me: What’s the ISBN?, When did you finish the book? and Any notes? Using the responses, the shortcut will then use GitHub’s create an issue endpoint and open the issue in my set repository.
Add the Finished a book iOS Shortcut
You will likely need to allow untrusted shortcuts to be able to add the shortcut. (But you should review the shortcut steps to make sure you understand all the actions it will take.)
Display your library
Since the file is a Jekyll data file, I can list all the books that I read this year.
I read 22 books in 2020 (so far).
{% assign sorted = site.data.read | sort: 'dateFinished' | where_exp:"item",
"item.dateFinished contains 2020" %}
<ul class="books">
{% for book in sorted %}
<li>
<a href="{{book.canonicalVolumeLink}}" class="book"><img src="{{book.imageLinks.thumbnail}}" alt="{{book.title}}"></a>
</li>
{% endfor %}
</ul>
I read {{sorted | size}} books in 2020 (so far).