Skip to content

Commit 4e4f91f

Browse files
committed
testing 3
1 parent b45840e commit 4e4f91f

3 files changed

Lines changed: 28 additions & 25 deletions

File tree

.github/workflows/sync-blogs.yml

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,20 @@ on:
55
types: [update_blog]
66
workflow_dispatch:
77
push:
8-
branches:
9-
- master
10-
- dev
8+
branches: [master, dev]
119
paths-ignore:
1210
- 'src/content/posts/**'
1311
- 'public/images/blog/**'
1412

1513
jobs:
16-
sync-blogs:
14+
sync-and-deploy:
1715
runs-on: ubuntu-latest
18-
permissions:
19-
contents: read
16+
# This runs the entire job inside a container that already has
17+
# Node, Chrome, and Mermaid CLI installed.
18+
container:
19+
image: minlag/mermaid-cli:latest
20+
options: --user root # Ensure we have permissions to write files
21+
2022
steps:
2123
- name: Checkout Main Repo
2224
uses: actions/checkout@v4
@@ -30,25 +32,19 @@ jobs:
3032
token: ${{ secrets.GH_PAT }}
3133
path: temp_blogs
3234

33-
- name: Setup Node.js
34-
uses: actions/setup-node@v4
35-
with:
36-
node-version: '20'
37-
38-
- name: Install Dependencies
35+
# Note: We skip 'Install Dependencies' for system libs
36+
# because they are already in the Docker image.
37+
38+
- name: Install Project Deps
3939
run: npm ci
4040

41-
- name: Install Mermaid CLI
42-
run: npm install -D @mermaid-js/mermaid-cli
43-
44-
- name: Install Puppeteer Dependencies
45-
# mmdc requires chrome/puppeteer which might need system deps
46-
run: |
47-
sudo apt-get update
48-
sudo apt-get install -y ca-certificates fonts-liberation libasound2 libatk-bridge2.0-0 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgbm1 libgcc1 libglib2.0-0 libgtk-3-0 libnspr4 libnss3 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 lsb-release wget xdg-utils
49-
5041
- name: Process Blogs
51-
run: node scripts/process-blogs.mjs
42+
run: |
43+
# Use the mmdc binary already present in the container
44+
node scripts/process-blogs.mjs
45+
env:
46+
# We tell the script to use the container's Chromium
47+
PUPPETEER_EXECUTABLE_PATH: /usr/bin/chromium-browser
5248

5349
- name: Build Project
5450
run: npm run build
@@ -59,4 +55,4 @@ jobs:
5955
repoToken: '${{ secrets.GITHUB_TOKEN }}'
6056
firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_WITHNUCLEUSAI_GITHUB_IO }}'
6157
channelId: live
62-
projectId: withnucleusai-github-io
58+
projectId: withnucleusai-github-io

puppeteer-config.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"args": [
3+
"--no-sandbox",
4+
"--disable-setuid-sandbox"
5+
]
6+
}

scripts/process-blogs.mjs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,9 @@ async function processBlogs() {
212212
const mmdPath = path.join(blogImagesDir, `temp-${hash}.mmd`);
213213
fs.writeFileSync(mmdPath, mermaidCode);
214214
try {
215-
execSync(`npx mmdc -i "${mmdPath}" -o "${imagePath}" -b white -s 3`, { stdio: 'inherit' });
216-
fs.unlinkSync(mmdPath);
215+
const mmdcCmd = process.env.PUPPETEER_EXECUTABLE_PATH ? 'mmdc' : 'npx mmdc';
216+
execSync(`${mmdcCmd} -p /puppeteer-config.json -i "${mmdPath}" -o "${imagePath}" -b white -s 3`, { stdio: 'inherit' });
217+
fs.unlinkSync(mmdPath);
217218
} catch (e) {
218219
console.error(` Failed to generate mermaid for ${slug}`, e);
219220
continue;

0 commit comments

Comments
 (0)