Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .github/workflows/screenshots.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand All @@ -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
Expand Down
8 changes: 5 additions & 3 deletions app/scripts/screenshots.mjs
Original file line number Diff line number Diff line change
@@ -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]
Expand Down Expand Up @@ -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,
Expand Down
Loading