WIP ParadisPerdu #139
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# puppeteer-cli PDF generation shortcomings: | |
# - relies on a call to the browser: Page.printToPDF - https://github.com/puppeteer/puppeteer/blob/v3.3.0/src/Page.ts#L1158 | |
# - chromium issue on adding metadata: https://bugs.chromium.org/p/chromium/issues/detail?id=907249 | |
# - PDFKit doc on this subject: https://github.com/foliojs/pdfkit/blob/master/docs/getting_started.md#setting-document-metadata | |
name: build | |
on: # cf. https://github.community/t/how-to-trigger-an-action-on-push-or-pull-request-but-not-both/16662 | |
push: | |
branches: | |
- master | |
tags: | |
- '*' | |
pull_request: | |
branches: | |
- master | |
jobs: | |
build-and-deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout 🛎️ | |
uses: actions/checkout@v2 | |
- name: Get latest release version number | |
id: tag | |
uses: battila7/get-version-action@v2 | |
- name: Set up NodeJS 🔧 | |
uses: actions/setup-node@v2 | |
with: | |
node-version: 18 | |
- name: Install dependencies ⚙️ | |
run: | | |
npm install | |
pip install -r requirements.txt | |
wget https://raw.githubusercontent.com/Lucas-C/dotfiles_and_notes/master/bin/md2html.js | |
- name: Generating HTML pages 🏗️ | |
run: | | |
GIT_TAG=${{ steps.tag.outputs.version }} | |
echo GIT_TAG=$GIT_TAG | |
node md2html.js index.md > index.html | |
node md2html.js LeDernierCafeSurLaGauche.md > LeDernierCafeSurLaGauche.html | |
echo "Rendering 2200_le_jugement_des_dieux" | |
cd 2200_le_jugement_des_dieux | |
node ../md2html.js 2200_le_jugement_des_dieux.md > index.html | |
node ../md2html.js 2200_the_gods_judgement.md > 2200_the_gods_judgement.html | |
if [[ $GIT_TAG =~ ^2200-le-jugement-des-dieux ]]; then | |
./gen_pdf.sh $GIT_TAG | |
fi | |
cd - | |
echo "Rendering CheatYourOwnAdventure" | |
cd CheatYourOwnAdventure | |
node ../md2html.js CheatYourOwnAdventure.md > index.html | |
cd - | |
if [[ $GIT_TAG =~ ^CyberPunk-v ]]; then | |
mv CyberPunk/CyberPunk-FR.pdf $GIT_TAG.pdf | |
fi | |
echo "Rendering DungeonHeartHeroesAndSpells" | |
cd DungeonHeartHeroesAndSpells | |
node ../md2html.js DungeonHeartHeroesAndSpells.md > index.html | |
node ../md2html.js --lang=en DungeonHeartHeroesAndSpells_en.md > DungeonHeartHeroesAndSpells_en.html | |
cd - | |
echo "Rendering ce-nest-pas-une-place-dhonneur" | |
cd ce-nest-pas-une-place-dhonneur | |
node ../md2html.js ce-nest-pas-une-place-dhonneur.md > index.html | |
if [[ $GIT_TAG =~ ^ce-nest-pas-une-place-dhonneur ]]; then | |
node ../puppeteer-print.js index.html ../$GIT_TAG.pdf | |
fi | |
cd - | |
echo "Rendering chimera" | |
cd chimera | |
node ../md2html.js chimera.md > index.html | |
if [[ $GIT_TAG =~ ^chimera ]]; then | |
node ../puppeteer-print.js index.html ../$GIT_TAG.pdf | |
fi | |
cd - | |
echo "Rendering gdav" | |
cd gdav | |
node ../md2html.js --title='Amères Victoires & Glorieuses Défaites' gdav.md > index.html | |
if [[ $GIT_TAG =~ ^gdav- ]]; then | |
sed -i "s/v[0-9]\.[0-9.]\+/${GIT_TAG/gdav-/}/" index.html | |
node ../puppeteer-print.js index.html ../$GIT_TAG.pdf | |
node ../puppeteer-print.js mind-map.html ../$GIT_TAG-mind-map.pdf | |
fi | |
cd - | |
echo "Rendering genius-loci" | |
cd genius-loci | |
node ../md2html.js genius-loci.md > index.html | |
cd - | |
echo "Rendering latour" | |
cd latour | |
node ../md2html.js latour.md > index.html | |
cd - | |
echo "Rendering LesNonMorts" | |
cd LesNonMorts | |
node ../md2html.js --title='Les Non-morts' LesNonMorts.md > index.html | |
if [[ $GIT_TAG =~ ^LesNonMorts- ]]; then | |
sed -i "s/v[0-9]\.[0-9.]\+/${GIT_TAG/LesNonMorts-/}/" index.html | |
node ../puppeteer-print.js index.html ../$GIT_TAG.pdf | |
fi | |
cd - | |
echo "Rendering OriMushi" | |
cd OriMushi | |
node ../md2html.js OriMushi.md > index.html | |
# This line cannot stay in the HTML source file due to lepture/python-livereload PR #259: | |
sed -i '1i<head><meta charset="UTF-8"></head>' OriMushi-FeuillePersonnage.html | |
node ../puppeteer-print.js OriMushi-FeuillePersonnage.html OriMushi-FeuillePersonnage.pdf | |
if [[ $GIT_TAG =~ ^ori-mushi- ]]; then | |
sed -i "s/{{version}}/${GIT_TAG/ori-mushi-/}/" index.html | |
node ../puppeteer-print.js index.html ../$GIT_TAG.pdf | |
fi | |
cd - | |
echo "Rendering Pathfinder" | |
cd Pathfinder | |
./build_pdf.py | |
cd - | |
echo "Rendering ParadisPerdu" | |
cd ParadisPerdu | |
pip install qrcode && ./gen_qrcodes.py | |
wget https://www.misterfrankenstein.com/wordpress/wp-content/uploads/2021/05/Pack_AP_ParadisPerdu.zip && unzip Pack_AP_ParadisPerdu.zip && rm Pack_AP_ParadisPerdu.zip | |
if [[ $GIT_TAG =~ ^ParadisPerdu-v ]]; then | |
sed -i "s/Version: [0-9].[0-9]/Version: ${GIT_TAG/ParadisPerdu-v/}/" README.md | |
fi | |
./adj2pdf.py | |
cd - | |
echo "Rendering plus-de-place-en-enfer" | |
cd plus-de-place-en-enfer | |
node ../md2html.js plus-de-place-en-enfer.md > index.html | |
cd - | |
echo "Rendering RunDieRepeat" | |
cd RunDieRepeat | |
node ../md2html.js RunDieRepeat-scenarios-FR.md > RunDieRepeat-scenarios-FR.html | |
if [[ $GIT_TAG =~ ^RunDieRepeat-scenarios- ]]; then | |
sed -i "s/v[0-9]\.[0-9.]\+/${GIT_TAG/RunDieRepeat-scenarios-/}/" RunDieRepeat-scenarios-FR.html | |
node ../puppeteer-print.js RunDieRepeat-scenarios-FR.html ../$GIT_TAG.pdf | |
fi | |
node ../md2html.js RunDieRepeat-scenarios2-FR.md > RunDieRepeat-scenarios2-FR.html | |
node ../puppeteer-print.js RunDieRepeat-scenarios2-FR.html RunDieRepeat-scenarios2-FR.pdf | |
node ../md2html.js RunDieRepeat-scenarios3-FR.md > RunDieRepeat-scenarios3-FR.html | |
node ../md2html.js DocteurLestrange.md > DocteurLestrange.html | |
if [[ $GIT_TAG =~ ^DocteurLestrange- ]]; then | |
sed -i "s/v[0-9]\.[0-9.]\+/${GIT_TAG/DocteurLestrange-/}/" DocteurLestrange.html | |
node ../puppeteer-print.js DocteurLestrange.html ../$GIT_TAG.pdf | |
fi | |
node ../md2html.js LesCouloirsDuTemps.md > LesCouloirsDuTemps.html | |
if [[ $GIT_TAG =~ ^LesCouloirsDuTemps- ]]; then | |
sed -i "s/v[0-9]\.[0-9.]\+/${GIT_TAG/LesCouloirsDuTemps-/}/" LesCouloirsDuTemps.html | |
node ../puppeteer-print.js LesCouloirsDuTemps.html ../$GIT_TAG.pdf | |
fi | |
cd - | |
echo "Rendering Sombre" | |
cd Sombre | |
Terminatrice/Terminatrice-BehindTheDoors.py | |
Terminatrice/Terminatrice-OutOfReach.py | |
cd scenario/ | |
if [[ $GIT_TAG =~ ^Sombre-LabEscape-v ]]; then | |
sed -i "s/Version: [0-9].[0-9]/Version: ${GIT_TAG/Sombre-LabEscape-v/}/" README.md | |
fi | |
./scenario2pdf.py | |
if [[ $GIT_TAG =~ ^Sombre-LabEscape-v ]]; then | |
mv ./Sombre-LabEscape.pdf ../../$GIT_TAG.pdf | |
fi | |
cd ../.. | |
echo "Rendering sous-terre" | |
cd sous-terre | |
node ../md2html.js sous-terre.md > index.html | |
cd - | |
echo "Rendering VengeanceFatale4D" | |
cd VengeanceFatale4D | |
node ../md2html.js VengeanceFatale4D.md > index.html | |
if [[ $GIT_TAG =~ ^VengeanceFatale4D ]]; then | |
sed -i "s/Version: [0-9].[0-9]/Version: ${GIT_TAG/VengeanceFatale4D-/}/" index.html | |
node ../puppeteer-print.js index.html ../$GIT_TAG.pdf | |
fi | |
cd - | |
echo "Rendering scavengers" | |
cd scavengers | |
node ../md2html.js scavengers.md > index.html | |
if [[ $GIT_TAG =~ ^adj-scavengers ]]; then | |
./gen_pdf.sh index.html ../$GIT_TAG.pdf | |
fi | |
cd - | |
# Build ZIP file for release: | |
if [[ $GIT_TAG != merge ]] && ! [[ $GIT_TAG =~ master ]]; then | |
zip $GIT_TAG.zip $GIT_TAG*.pdf | |
fi | |
# Copying current directory in the output public/ subdirectory: | |
rm -r .gitignore node_modules/ | |
mkdir ../public/ && cp -r . ../public/ && mv ../public/ . | |
- name: Statically checking generated HTML files 🔎 | |
run: | | |
wget https://github.com/htacg/tidy-html5/releases/download/5.4.0/tidy-5.4.0-64bit.deb | |
sudo dpkg -i --force-overwrite tidy-5.4.0-64bit.deb && rm tidy-5.4.0-64bit.deb | |
for html_file in public/*.html public/*/*.html; do | |
# We ignore versioned .html files: | |
git ls-files --error-unmatch $html_file >/dev/null 2>&1 && continue | |
# We ignore "partial" HTML files: | |
grep -F '<html' $html_file >/dev/null || continue | |
echo Tidying $html_file | |
tidy -quiet -modify -config htmltidy.conf $html_file | |
done | |
- name: Deploy website 🚀 | |
uses: peaceiris/actions-gh-pages@v3 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_dir: public/ | |
# Release-only steps: | |
- name: Create Release | |
if: contains(github.ref, '-v') | |
uses: actions/create-release@v1 | |
id: create_release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ steps.tag.outputs.version }} | |
release_name: ${{ steps.tag.outputs.version }} | |
- name: Upload ZIP | |
if: contains(github.ref, '-v') | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./${{ steps.tag.outputs.version }}.zip | |
asset_name: ${{ steps.tag.outputs.version }}.zip | |
asset_content_type: application/zip | |
- name: Deploy on itch.io 🚀 | |
if: contains(github.ref, '-v') | |
run: ./publish-on-itch.io.sh ${{ github.ref }} | |
env: | |
BUTLER_API_KEY: ${{ secrets.BUTLER_API_KEY }} |