chore: autogen pdf from md #2
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
name: Convert MD to PDF | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
convert-webpage: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Install dependencies | |
run: | | |
npm install puppeteer | |
npm install live-server | |
- name: Start live-server to serve the webpage | |
run: | | |
npx live-server docs & | |
sleep 5 | |
- name: Convert webpage to PDF using puppeteer | |
run: | | |
node -e " | |
const puppeteer = require('puppeteer'); | |
(async () => { | |
const browser = await puppeteer.launch(); | |
const page = await browser.newPage(); | |
await page.goto('http://localhost:8080/#', { waitUntil: 'networkidle2' }); | |
await page.pdf({ path: 'docs/slides.pdf', format: 'A4' }); | |
await browser.close(); | |
})(); | |
" | |
- name: Upload PDF artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: slides-pdf | |
path: docs/slides.pdf |