name: Reading
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
      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/read-action@v8.1.0
        with:
          filename: src/_data/json/read.json
          time-zone: America/Los_Angeles
          thumbnail-width: 512

      - name: Commit updated read file
        run: |
          git pull
          git config --local user.email "hi@coryd.dev"
          git config --local user.name "Cory Dransfeldt"
          git add -A && git commit -m "📚 “${{ env.BookTitle }}” (${{ env.BookStatus }})"
          git push