Skip to content

Commit

Permalink
Add CI/CD pipeline to generate PDF
Browse files Browse the repository at this point in the history
  • Loading branch information
lpsinger committed Oct 17, 2023
1 parent 06ea18a commit 29035cb
Show file tree
Hide file tree
Showing 4 changed files with 116 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/pdf.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: PDF
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
pdf:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
- name: NPM Install
run: npm ci
- name: Export PDF
run: npm run pdf
- uses: actions/upload-artifact@v3
with:
name: pdf
path: index.pdf
70 changes: 70 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"type": "module",
"scripts": {
"pdf": "node pdf.js"
},
"devDependencies": {
"@playwright/browser-chromium": "^1.39.0",
"playwright": "^1.39.0"
}
}
11 changes: 11 additions & 0 deletions pdf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { pathToFileURL } from 'node:url'
import { chromium } from 'playwright'

const browser = await chromium.launch()
try {
const page = await browser.newPage()
await page.goto(`${pathToFileURL('index.html')}?print-pdf`)
await page.pdf({ path: 'index.pdf', landscape: true, printBackground: true })
} finally {
await browser.close()
}

0 comments on commit 29035cb

Please sign in to comment.