Move to weasyprint
This commit is contained in:
@@ -1,9 +1,9 @@
|
|||||||
name: Build
|
name: Build and Publish
|
||||||
run-name: Building latest version of my resume 🚀
|
run-name: Building latest version of my resume 🚀
|
||||||
on: [push]
|
on: [push]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
Build_And_Publish:
|
build_html:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container: node:latest
|
container: node:latest
|
||||||
steps:
|
steps:
|
||||||
@@ -16,12 +16,23 @@ jobs:
|
|||||||
- name: List files in the repository
|
- name: List files in the repository
|
||||||
run: |
|
run: |
|
||||||
ls ${{ gitea.workspace }}
|
ls ${{ gitea.workspace }}
|
||||||
|
|
||||||
|
convert_to_pdf:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Install weasyprint
|
||||||
|
run: |
|
||||||
|
sudo apt update && sudo apt install weasyprint -y
|
||||||
- name: Convert to pdf
|
- name: Convert to pdf
|
||||||
run: |
|
run: |
|
||||||
npx puppeteer-cli print generated_resume.html resume.pdf
|
weasyprint generated_resume.html resume.pdf
|
||||||
- name: List files in the repository
|
- name: List files in the repository
|
||||||
run: |
|
run: |
|
||||||
ls ${{ gitea.workspace }}
|
ls ${{ gitea.workspace }}
|
||||||
|
|
||||||
|
upload_as_release:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
- name: Create Release
|
- name: Create Release
|
||||||
uses: akkuman/gitea-release-action@v1
|
uses: akkuman/gitea-release-action@v1
|
||||||
with:
|
with:
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
[
|
[
|
||||||
{
|
{
|
||||||
"label": "Build",
|
"label": "Build",
|
||||||
"command": "npm run build",
|
"command": "npm run build && weasyprint generated_resume.html resume.pdf",
|
||||||
"use_new_terminal": false,
|
"use_new_terminal": false,
|
||||||
"allow_concurrent_runs": false,
|
"allow_concurrent_runs": false,
|
||||||
"reveal": "always",
|
"reveal": "always",
|
||||||
|
|||||||
19
build.js
19
build.js
@@ -1,7 +1,6 @@
|
|||||||
const ejs = require("ejs");
|
const ejs = require("ejs");
|
||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
const puppeteer = require("puppeteer");
|
|
||||||
|
|
||||||
// File paths
|
// File paths
|
||||||
const dataPath = path.join(__dirname, "content.json");
|
const dataPath = path.join(__dirname, "content.json");
|
||||||
@@ -18,20 +17,4 @@ const html = ejs.render(template, jsonData);
|
|||||||
// Write the output
|
// Write the output
|
||||||
fs.writeFileSync(outputPath, html, "utf-8");
|
fs.writeFileSync(outputPath, html, "utf-8");
|
||||||
|
|
||||||
console.log(`Successfully generated resume at ${outputPath}`);
|
console.log(`Successfully generated html resume at ${outputPath}`);
|
||||||
|
|
||||||
async function generatePdf(htmlPath) {
|
|
||||||
const browser = await puppeteer.launch();
|
|
||||||
const page = await browser.newPage();
|
|
||||||
await page.goto(`file://${htmlPath}`, {
|
|
||||||
waitUntil: "networkidle2",
|
|
||||||
});
|
|
||||||
// Saves the PDF to hn.pdf.
|
|
||||||
await page.pdf({
|
|
||||||
path: "resume.pdf",
|
|
||||||
});
|
|
||||||
|
|
||||||
await browser.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
generatePdf(outputPath).then(() => console.log("Generated PDF version"));
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
devShells.default = pkgs.mkShell {
|
devShells.default = pkgs.mkShell {
|
||||||
buildInputs = with pkgs; [
|
buildInputs = with pkgs; [
|
||||||
nodejs
|
nodejs
|
||||||
chromium
|
python313Packages.weasyprint
|
||||||
|
|
||||||
jq
|
jq
|
||||||
curl
|
curl
|
||||||
|
|||||||
1108
package-lock.json
generated
1108
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -4,10 +4,9 @@
|
|||||||
"description": "Builds an HTML resume from JSON data",
|
"description": "Builds an HTML resume from JSON data",
|
||||||
"main": "build.js",
|
"main": "build.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "node build.js"
|
"build": "node build.js && weasyprint generated_resume.html resume.pdf"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"ejs": "^3.1.8",
|
"ejs": "^3.1.8"
|
||||||
"puppeteer": "^24.32.1"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user