|
| 1 | +###################################### |
| 2 | +## Custom Web Almanac GitHub action ## |
| 3 | +###################################### |
| 4 | +# |
| 5 | +# A script that must be run in GitHub Actions to generate the ebooks. |
| 6 | +# Useful for those that don't have prince installed locally. |
| 7 | +# |
| 8 | +name: Generate ebooks |
| 9 | + |
| 10 | +env: |
| 11 | + # Update periodically from https://www.princexml.com/latest/ |
| 12 | + PRINCE_PACKAGE: 'prince_16.1-1_ubuntu24.04_amd64.deb' |
| 13 | + |
| 14 | +on: |
| 15 | + workflow_dispatch: |
| 16 | + |
| 17 | +jobs: |
| 18 | + build: |
| 19 | + name: Generate Ebooks |
| 20 | + runs-on: ubuntu-latest |
| 21 | + steps: |
| 22 | + - name: Checkout branch |
| 23 | + uses: actions/checkout@v7 |
| 24 | + - name: Setup Node.js for use with actions |
| 25 | + uses: actions/setup-node@v7 |
| 26 | + with: |
| 27 | + node-version: '24' |
| 28 | + - name: Set up Python 3.12 |
| 29 | + uses: actions/setup-python@v7 |
| 30 | + with: |
| 31 | + python-version: '3.12' |
| 32 | + - name: Install Asian Fonts |
| 33 | + if: ${{ github.event.inputs.ebooks == 'true' }} |
| 34 | + run: | |
| 35 | + # Install Japanese san-serif font |
| 36 | + sudo apt-get install -y fonts-ipafont-gothic |
| 37 | + # Install Chinese san-serif font |
| 38 | + sudo apt-get install -y fonts-arphic-uming |
| 39 | + # Install Korean san-serif font |
| 40 | + sudo apt-get install -y fonts-unfonts-core |
| 41 | + - name: Install PrinceXML |
| 42 | + if: ${{ github.event.inputs.ebooks == 'true' }} |
| 43 | + run: | |
| 44 | + wget https://www.princexml.com/download/${{ env.PRINCE_PACKAGE }} --directory-prefix=/tmp |
| 45 | + DEBIAN_FRONTEND=noninteractive sudo apt install -y /tmp/${{ env.PRINCE_PACKAGE }} |
| 46 | + - name: Install pdftk |
| 47 | + if: ${{ github.event.inputs.ebooks == 'true' }} |
| 48 | + run: sudo apt install pdftk |
| 49 | + - name: Run the website |
| 50 | + run: ./src/tools/scripts/run_and_test_website.sh |
| 51 | + - name: Generating Ebooks |
| 52 | + run: | |
| 53 | + cd src |
| 54 | + mkdir static/pdfs/ |
| 55 | + npm run ebooks |
| 56 | + - name: Upload PDF artifact |
| 57 | + if: ${{ github.event.inputs.ebooks == 'true' }} |
| 58 | + uses: actions/upload-artifact@v7 |
| 59 | + with: |
| 60 | + name: pdfs |
| 61 | + path: ./src/static/pdfs/*.pdf |
| 62 | + if-no-files-found: warn # 'warn' or 'ignore' are also available, defaults to `warn` |
| 63 | + retention-days: 5 # defaults to 90 |
0 commit comments