From d799af4c3d4ba7a5b959ccfe970a97c608c88671 Mon Sep 17 00:00:00 2001 From: hex-dump <119895168+hex-dump@users.noreply.github.com> Date: Tue, 17 Nov 2026 14:13:16 +0100 Subject: [PATCH] Screenshots: write to a known folder that is created first Co-Authored-By: Claude Opus 5.5 --- .github/workflows/screenshots.yml | 6 ++++-- app/scripts/screenshots.mjs | 8 +++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.github/workflows/screenshots.yml b/.github/workflows/screenshots.yml index 6097fef..e12fba8 100644 --- a/.github/workflows/screenshots.yml +++ b/.github/workflows/screenshots.yml @@ -48,12 +48,14 @@ jobs: working-directory: app env: CHROME: google-chrome + SHOTS_DIR: ${{ runner.temp }}/shots run: | npm ci npm run screenshots - name: Commit what changed env: + SHOTS_DIR: ${{ runner.temp }}/shots GH_TOKEN: ${{ github.token }} LABEL: ${{ github.event.release.tag_name || inputs.tag || github.run_id }} run: | @@ -66,8 +68,8 @@ jobs: fi rm -rf "$RUNNER_TEMP/assets/screenshots" mkdir "$RUNNER_TEMP/assets/screenshots" - cp docs/screenshots/*.png "$RUNNER_TEMP/assets/screenshots/" - cp docs/social-preview.png "$RUNNER_TEMP/assets/" + cp "$SHOTS_DIR"/screenshots/*.png "$RUNNER_TEMP/assets/screenshots/" + cp "$SHOTS_DIR/social-preview.png" "$RUNNER_TEMP/assets/" cd "$RUNNER_TEMP/assets" git add -A if git diff --cached --quiet; then diff --git a/app/scripts/screenshots.mjs b/app/scripts/screenshots.mjs index f177210..91029b6 100644 --- a/app/scripts/screenshots.mjs +++ b/app/scripts/screenshots.mjs @@ -1,17 +1,18 @@ // Screenshots of the interface for the README and the website (docs/screenshots) and the social // preview (docs/social-preview.png), from the preview build (vite.preview.config.ts, preview/fake.ts). +// Output goes to SHOTS_DIR (default: docs/), created if missing: Chrome does not make folders. // Needs Chrome or Chromium: set CHROME to its path if it is not found. // npm run screenshots import { execFile, spawnSync } from "node:child_process"; import { promisify } from "node:util"; -import { mkdtempSync, rmSync } from "node:fs"; +import { mkdirSync, mkdtempSync, rmSync } from "node:fs"; import { tmpdir } from "node:os"; -import { join, resolve } from "node:path"; +import { dirname, join, resolve } from "node:path"; import { build, preview } from "vite"; const app = resolve(import.meta.dirname, ".."); -const docs = resolve(app, "../docs"); +const docs = resolve(process.env.SHOTS_DIR || resolve(app, "../docs")); const config = resolve(app, "vite.preview.config.ts"); // [file, page as the app's address says it, width, height] @@ -41,6 +42,7 @@ const profile = mkdtempSync(join(tmpdir(), "perihub-shots-")); try { for (const [file, page, width, height] of shots) { const out = join(docs, file); + mkdirSync(dirname(out), { recursive: true }); // Asynchronous: the preview server runs in this process and must keep answering. await promisify(execFile)( browser,