Skip to content

Commit

Permalink
Merge pull request #7 from kamilogorek/master
Browse files Browse the repository at this point in the history
ci: Use signcl/docusaurus-prince-pdf to generate pdf version of the book
  • Loading branch information
jwalton committed Apr 26, 2023
2 parents 63fd623 + bd58569 commit 68d3801
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 5 deletions.
59 changes: 54 additions & 5 deletions .github/workflows/deploy-gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@ on:
- master

jobs:
deploy:
name: Build and Deploy
build:
name: Build
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
Expand All @@ -24,6 +22,24 @@ jobs:
run: npm ci
- name: Build
run: npm run build
- name: Upload build artifacts
uses: actions/upload-artifact@v3
with:
name: build-output
path: build/

deploy:
name: Deploy
runs-on: ubuntu-latest
needs: build
permissions:
contents: write
steps:
- name: Download build artifacts
uses: actions/download-artifact@v3
with:
name: build-output
path: build/
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
if: ${{ github.ref == 'refs/heads/master' }}
Expand All @@ -32,4 +48,37 @@ jobs:
# Build output to publish to the `gh-pages` branch:
publish_dir: ./build
user_name: jwalton
user_email: dev@lucid.thedreaming.org
user_email: dev@lucid.thedreaming.org

pdf:
name: Generate PDF Version
runs-on: ubuntu-latest
needs: build
steps:
- name: Download build artifacts
uses: actions/download-artifact@v3
with:
name: build-output
path: build/
- name: Install Prince (HTML to PDF converter)
run: |
curl https://www.princexml.com/download/prince-14.2-linux-generic-x86_64.tar.gz -O
tar zxf prince-14.2-linux-generic-x86_64.tar.gz
cd prince-14.2-linux-generic-x86_64
yes "" | sudo ./install.sh
- name: Start Server and Build PDF
run: |
# Symlink to make docusaurus `baseUrl` working
ln -s ./build rust-book-abridged
# Start local server and wait for it to be ready
npx serve . -p 1337 & npx wait-on http://localhost:1337/rust-book-abridged
# Generate PDF
npx docusaurus-prince-pdf -u http://localhost:1337/rust-book-abridged --output rust-book-abridged.pdf
# Kill server
fuser -k 1337/tcp
- name: Upload PDF Artifact
uses: actions/upload-artifact@v3
with:
name: rust-book-abridged.pdf
path: rust-book-abridged.pdf
if-no-files-found: error
8 changes: 8 additions & 0 deletions src/css/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,11 @@
--ifm-color-primary-lightest: #ffb3b3;
--docusaurus-highlighted-code-line-bg: rgba(0, 0, 0, 0.3);
}

/* This works around the issue of truncated code-blocks in https://github.com/signcl/docusaurus-prince-pdf/ */
@media print {
code[class*='codeBlockLines'] {
float: none;
display: block;
}
}

0 comments on commit 68d3801

Please sign in to comment.