-
-
Notifications
You must be signed in to change notification settings - Fork 176
94 lines (90 loc) · 2.99 KB
/
predeploy.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
######################################
## 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 }}"