Update make_test_ebook.yaml (#23)

- Added ability to dynamically get epub filename from git log
This commit is contained in:
cao 2023-03-04 18:31:38 +08:00 committed by GitHub
parent 6e22cfb7df
commit 1840a4932a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,17 +1,24 @@
name: CI
name: CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
jobs:
testing:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Get epub filename
run: |
EPUB_FILENAME_BASE=$(git log --diff-filter=A --name-only --pretty=format: | grep -E "^test_books/.*\.epub$" | head -n 1 | xargs -0 -I {} basename "{}" | sed 's/\.epub//')
echo "EPUB_FILENAME_BASE=$EPUB_FILENAME_BASE" >> $GITHUB_ENV
- name: install python 3.9
uses: actions/setup-python@v4
with:
@ -26,4 +33,9 @@ jobs:
- name: make test ebook
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
run: python3 make_book.py --book_name test_books/animal_farm.epub --no_limit --test --test_num 2 --language zh-hans
run: python3 make_book.py --book_name "test_books/${{ env.EPUB_FILENAME_BASE}}.epub" --no_limit --test --test_num 2 --language zh-hans
- name: Rename and Upload ePub
uses: actions/upload-artifact@v2
with:
name: epub_output
path: "test_books/${{ env.EPUB_FILENAME_BASE }}_bilingual.epub"