|
| 1 | +# GitHub workflow for generating test files and deploying to gh-pages |
| 2 | + |
| 3 | +name: Generate Test Files and Deploy to gh-pages |
| 4 | + |
| 5 | +# Controls when the action will run. |
| 6 | +on: |
| 7 | + # Triggers the workflow on push to main branch |
| 8 | + push: |
| 9 | + branches: [ main ] |
| 10 | + # Allows you to run this workflow manually from the Actions tab |
| 11 | + workflow_dispatch: |
| 12 | + |
| 13 | +# A workflow run is made up of one or more jobs that can run sequentially or in parallel |
| 14 | +jobs: |
| 15 | + # This workflow contains a single job called "build-and-deploy" |
| 16 | + build-and-deploy: |
| 17 | + # The type of runner that the job will run on |
| 18 | + runs-on: ubuntu-latest |
| 19 | + permissions: |
| 20 | + contents: write |
| 21 | + |
| 22 | + # Steps represent a sequence of tasks that will be executed as part of the job |
| 23 | + steps: |
| 24 | + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it |
| 25 | + - uses: actions/checkout@v2 |
| 26 | + |
| 27 | + # Sets up python |
| 28 | + - uses: actions/setup-python@v2 |
| 29 | + with: |
| 30 | + python-version: 3.10 |
| 31 | + |
| 32 | + # Install dependencies |
| 33 | + - name: "Installs dependencies" |
| 34 | + run: | |
| 35 | + python3 -m pip install --upgrade pip |
| 36 | + python3 -m pip install setuptools wheel tqdm minify-html watchdog |
| 37 | +
|
| 38 | + # Build and install the project |
| 39 | + - name: "Builds and installs the project" |
| 40 | + run: | |
| 41 | + python3 setup.py sdist bdist_wheel |
| 42 | + python3 -m pip install -e . --break-system-packages |
| 43 | +
|
| 44 | + # Generate test files |
| 45 | + - name: "Generates test files" |
| 46 | + run: | |
| 47 | + # Check if there are any EPUB files in examples directory |
| 48 | + if [ -z "$(ls -A examples/*.epub 2>/dev/null)" ]; then |
| 49 | + echo "No EPUB files found in examples directory" |
| 50 | + exit 1 |
| 51 | + fi |
| 52 | + # Generate test files |
| 53 | + epub-browser ./examples --no-server --output-dir ./test --keep-files |
| 54 | +
|
| 55 | + # Deploy to gh-pages |
| 56 | + - name: "Deploys to gh-pages" |
| 57 | + uses: peaceiris/actions-gh-pages@v3 |
| 58 | + with: |
| 59 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 60 | + publish_dir: ./test |
| 61 | + publish_branch: gh-pages |
| 62 | + force_orphan: true |
| 63 | + commit_message: "Update test files" |
0 commit comments