Skip to content

Commit efb6508

Browse files
committed
bring back predeploy
1 parent 9a686fb commit efb6508

1 file changed

Lines changed: 94 additions & 0 deletions

File tree

.github/workflows/predeploy.yml

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
######################################
2+
## Custom Web Almanac GitHub action ##
3+
######################################
4+
#
5+
# A pre-deploy script that must be run in GitHub Actions to:
6+
# - Update timestamps and hashes
7+
# - Generate the ebooks
8+
# - Upload ebooks as artifacts
9+
# - Submit a Pull Request with the changes
10+
#
11+
# This should be run before every release
12+
#
13+
name: Predeploy script
14+
15+
env:
16+
# Update periodically from https://www.princexml.com/latest/
17+
PRINCE_PACKAGE: 'prince_16.1-1_ubuntu24.04_amd64.deb'
18+
19+
on:
20+
workflow_dispatch:
21+
inputs:
22+
ebooks:
23+
type: boolean
24+
description: "Regenerate Ebooks?"
25+
required: true
26+
default: "true"
27+
28+
jobs:
29+
build:
30+
name: Update Timestamps and Generate Ebooks
31+
runs-on: ubuntu-latest
32+
steps:
33+
- name: Checkout branch
34+
uses: actions/checkout@v6
35+
- name: Setup Node.js for use with actions
36+
uses: actions/setup-node@v6
37+
with:
38+
node-version: '20'
39+
- name: Set up Python 3.12
40+
uses: actions/setup-python@v6
41+
with:
42+
python-version: '3.12'
43+
- name: Install Asian Fonts
44+
if: ${{ github.event.inputs.ebooks == 'true' }}
45+
run: |
46+
# Install Japanese san-serif font
47+
sudo apt-get install -y fonts-ipafont-gothic
48+
# Install Chinese san-serif font
49+
sudo apt-get install -y fonts-arphic-uming
50+
# Install Korean san-serif font
51+
sudo apt-get install -y fonts-unfonts-core
52+
- name: Install PrinceXML
53+
if: ${{ github.event.inputs.ebooks == 'true' }}
54+
run: |
55+
wget https://www.princexml.com/download/${{ env.PRINCE_PACKAGE }} --directory-prefix=/tmp
56+
DEBIAN_FRONTEND=noninteractive sudo apt install -y /tmp/${{ env.PRINCE_PACKAGE }}
57+
- name: Install pdftk
58+
if: ${{ github.event.inputs.ebooks == 'true' }}
59+
run: sudo apt install pdftk
60+
- name: Run the website
61+
run: ./src/tools/scripts/run_and_test_website.sh
62+
- name: Generating Ebooks
63+
if: ${{ github.event.inputs.ebooks == 'true' }}
64+
run: |
65+
cd src
66+
mkdir static/pdfs/
67+
npm run ebooks
68+
- name: Upload PDF artifact
69+
if: ${{ github.event.inputs.ebooks == 'true' }}
70+
uses: actions/upload-artifact@v7
71+
with:
72+
name: pdfs
73+
path: ./src/static/pdfs/*.pdf
74+
if-no-files-found: warn # 'warn' or 'ignore' are also available, defaults to `warn`
75+
retention-days: 5 # defaults to 90
76+
- name: Update timestamps
77+
run: |
78+
cd src
79+
npm run timestamps
80+
- name: Create Pull Request
81+
id: cpr
82+
uses: peter-evans/create-pull-request@v8
83+
with:
84+
title: Pre-deploy Updates
85+
branch-suffix: timestamp
86+
commit-message: Update Timestamps
87+
body: |
88+
Updated Timestamps through GitHub action
89+
- Auto-generated by [create-pull-request][1] GitHub Action
90+
91+
[1]: https://github.com/peter-evans/create-pull-request
92+
labels: generate chapters
93+
- name: Check outputs
94+
run: echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"

0 commit comments

Comments
 (0)