Skip to content

Python EpubLoader Workflow #28

Python EpubLoader Workflow

Python EpubLoader Workflow #28

name: Python EpubLoader Workflow
on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:
jobs:
build-and-run:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install dependencies
run: |
pip install poetry
poetry config virtualenvs.create false
poetry install --no-root
- name: Copy input.epub and config.yaml
run: |
python download.py output/${{ vars.CN_TITLE }} ${{ vars.CN_TITLE }} ${{ secrets.S3_ACCESS_KEY }} ${{ secrets.S3_SECRET_KEY }} ${{ secrets.S3_ENDPOINT }} ${{ secrets.S3_BUCKET_NAME }}
if [ -n "${{ secrets.TRANSLATION_CONFIG }}" ]; then
echo "${{ secrets.TRANSLATION_CONFIG }}" > translation.yaml
else
sed -i 's/POE-API-KEY/'"${{ secrets.POE_API_KEY }}"'/g' translation.yaml.example
sed -i 's/GOOGLE-API-KEY/'"${{ secrets.GOOGLE_API_KEY }}"'/g' translation.yaml.example
mv translation.yaml.example translation.yaml
fi
sed -i 's/CN-TITLE/'"${{ vars.CN_TITLE }}"'/g' .env.example
sed -i 's/JP-TITLE/'"${{ vars.JP_TITLE }}"'/g' .env.example
sed -i 's/PROMPT-EXAMPLE/'"${{ vars.PROMPT }}"'/g' .env.example
sed -i 's/TRANSLATION-TITLE-RETRY-COUNT/'"${{ vars.TRANSLATION_TITLE_RETRY_COUNT }}"'/g' .env.example
mv .env.example .env
cat .env
- name: Run epubloader.py script
run: |
python monitor.py output/${{ vars.CN_TITLE }} ${{ vars.CN_TITLE }} ${{ secrets.S3_ACCESS_KEY }} ${{ secrets.S3_SECRET_KEY }} ${{ secrets.S3_ENDPOINT }} ${{ secrets.S3_BUCKET_NAME }} &
if [ "${{ vars.DRYRUN }}" = "True" ]; then
python epubloader.py --dryrun
else
python epubloader.py
fi
python monitor.py output/${{ vars.CN_TITLE }} ${{ vars.CN_TITLE }} ${{ secrets.S3_ACCESS_KEY }} ${{ secrets.S3_SECRET_KEY }} ${{ secrets.S3_ENDPOINT }} ${{ secrets.S3_BUCKET_NAME }} --final