Skip to content

Predeploy script

Predeploy script #194

Workflow file for this run

######################################
## Custom Web Almanac GitHub action ##
######################################
#
# A pre-deploy script that must be run in GitHub Actions to:
# - Update timestamps and hashes
# - Generate the ebooks
# - Upload ebooks as artifacts
# - Submit a Pull Request with the changes
#
# This should be run before every release
#
name: Predeploy script
env:
# Update periodically from https://www.princexml.com/latest/
PRINCE_PACKAGE: 'prince_13.6-1_ubuntu20.04_amd64.deb'
on:
workflow_dispatch:
inputs:
ebooks:
type: boolean
description: "Regenerate Ebooks?"
required: true
default: "true"
jobs:
build:
name: Update Timestamps and Generate Ebooks
runs-on: ubuntu-20.04
steps:
- name: Checkout branch
uses: actions/checkout@v4
- name: Setup Node.js for use with actions
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Set up Python 3.8
uses: actions/[email protected]
with:
python-version: '3.8'
- name: Install Asian Fonts
if: ${{ github.event.inputs.ebooks == 'true' }}
run: |
# Install Japanese san-serif font
sudo apt-get install -y fonts-ipafont-gothic
# Install Chinese san-serif font
sudo apt-get install -y fonts-arphic-uming
# Install Korean san-serif font
sudo apt-get install -y fonts-unfonts-core
- name: Install PrinceXML
if: ${{ github.event.inputs.ebooks == 'true' }}
run: |
wget https://www.princexml.com/download/${{ env.PRINCE_PACKAGE }} --directory-prefix=/tmp
DEBIAN_FRONTEND=noninteractive sudo apt install -y /tmp/${{ env.PRINCE_PACKAGE }}
- name: Install pdftk
if: ${{ github.event.inputs.ebooks == 'true' }}
run: sudo apt install pdftk
- name: Run the website
run: ./src/tools/scripts/run_and_test_website.sh
- name: Generating Ebooks
if: ${{ github.event.inputs.ebooks == 'true' }}
run: |
cd src
mkdir static/pdfs/
npm run ebooks
- name: Upload PDF artifact
if: ${{ github.event.inputs.ebooks == 'true' }}
uses: actions/upload-artifact@v4
with:
name: pdfs
path: ./src/static/pdfs/*.pdf
if-no-files-found: warn # 'warn' or 'ignore' are also available, defaults to `warn`
retention-days: 5 # defaults to 90
- name: Update timestamps
run: |
cd src
npm run timestamps
- name: Create Pull Request
id: cpr
uses: peter-evans/create-pull-request@v6
with:
title: Pre-deploy Updates
branch-suffix: timestamp
commit-message: Update Timestamps
body: |
Updated Timestamps through GitHub action
- Auto-generated by [create-pull-request][1] GitHub Action
[1]: https://github.com/peter-evans/create-pull-request
labels: generate chapters
- name: Check outputs
run: echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"