From bbcaab22f9c9860baff7b688ab6bccb8c78ed06c Mon Sep 17 00:00:00 2001 From: mat-0 Date: Wed, 8 Nov 2023 19:49:32 +0000 Subject: [PATCH] Update add-book.yml --- .github/workflows/add-book.yml | 66 ++++++++++++++++++++-------------- 1 file changed, 39 insertions(+), 27 deletions(-) diff --git a/.github/workflows/add-book.yml b/.github/workflows/add-book.yml index 549fdf6f..e14b02e3 100644 --- a/.github/workflows/add-book.yml +++ b/.github/workflows/add-book.yml @@ -1,41 +1,53 @@ --- name: Add Book +run-name: Book (${{ inputs.isbn }}) + +# Grant the action permission to write to the repository +permissions: + contents: write + +# Trigger the action on: - issues: - types: [labeled, edited] -env: - content: ${{ github.event.issue.body }} - label: ${{ github.event.label.name }} - issue_number: ${{ github.event.issue.number }} - actor: ${{ github.actor }} - owner: ${{ github.repository_owner }} + workflow_dispatch: + inputs: + isbn: + description: The book's ISBN. Required. + required: true + type: string + notes: + description: Notes about the book. Optional. + type: string + # If you do not submit date-started or date-finished, the book status will be set to "want to read" + date-started: + description: Date you started the book (YYYY-MM-DD). Optional. + type: string + date-finished: + description: Date you finished the book (YYYY-MM-DD). Optional. + type: string + +# Set up the steps to run the action jobs: - Checks: - if: contains( github.event.issue.labels.*.name, 'read') - runs-on: ubuntu-latest - steps: - - name: Echo - run: echo "Label is $label" - Build: - needs: Checks - if: ${{ github.actor == github.repository_owner }} - runs-on: ubuntu-latest + update-library: + runs-on: macOS-latest + name: Read steps: - name: Checkout uses: actions/checkout@v4 + - name: Read uses: katydecorah/read-action@v7.3.0 + with: + thumbnail-width: 1280 + - name: Download the book thumbnail + if: env.BookThumbOutput != '' + run: curl "${{ env.BookThumb }}" -o "img/${{ env.BookThumbOutput }}" + + - name: Commit updated read file run: | - curl "${{env.BookThumb}}" -o "images/books/${{env.BookThumbOutput}}" - - name: Commit files - run: | + git pull git config --local user.email "action@github.com" git config --local user.name "GitHub Action" - git add -A && git commit -m "Added ${{ env.BookTitle }}" + git add -A && git commit -m "📚 “${{ env.BookTitle }}” (${{ env.BookStatus }})" git push - - name: Close issue - uses: peter-evans/close-issue@v3 - with: - issue-number: "${{ env.IssueNumber }}" - comment: "📚 You read ${{ env.BookTitle }} on ${{env.DateRead}}." +