Skip to content

Random Book Fetch and Release #47

Random Book Fetch and Release

Random Book Fetch and Release #47

Workflow file for this run

name: Random Book Fetch and Release
on:
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
jobs:
fetch-and-release:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
- name: Network Test
run: |
curl -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Firefox/91.0" \
-H "Accept-Language: en-GB,en;q=0.9,zh-CN;q=0.8,zh;q=0.7" \
-H "Cache-Control: max-age=0" \
-H "Dnt: 1" \
-H "Priority: u=0, i" \
-vvv https://se8.us/
- name: Run random book fetch script
run: |
source venv/bin/activate
python manage.py random_book_get
ZIP_PASSWORD=$(date +%Y-%m-%d)
BOOK_NAME=$(cat books/name)
ZIP_NAME="$BOOK_NAME-$ZIP_PASSWORD.zip"
ZIP_PATH="./$ZIP_NAME"
echo "ZIP_PATH=$ZIP_PATH" >> $GITHUB_ENV
echo "ZIP_NAME=$ZIP_NAME" >> $GITHUB_ENV
zip -e -P "$ZIP_PASSWORD" "$ZIP_NAME" books/*.pdf
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.ACTION_AUTO }}
with:
tag_name: ${{ github.run_id }}
release_name: ${{ env.ZIP_NAME }}
draft: false
prerelease: false
- name: Upload ZIP files to Release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.ACTION_AUTO }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ env.ZIP_PATH }}
asset_name: ${{ env.ZIP_NAME }}
asset_content_type: application/zip