-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathscreenshot.sh
More file actions
executable file
·34 lines (29 loc) · 930 Bytes
/
Copy pathscreenshot.sh
File metadata and controls
executable file
·34 lines (29 loc) · 930 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/sh
set -eux
# To avoid interfering with the host's node_modules, copy everything
# to a temporary dir and then blat the node stuff.
SITE_COPY=$(mktemp -d --tmpdir chameth.com-screenshot.XXXXXXXX)
cp -a . "$SITE_COPY"
rm -rf "$SITE_COPY/node_modules"
# Build the site
podman run --rm \
-v "$SITE_COPY:/site:U" \
--entrypoint /bin/sh \
oven/bun:latest \
-c '
set -eux
cd /site
bun ci
bun run build
'
# Run puppeteer to take the screenshot. This runs as the puppeteer user
# as that's where the puppeteer stuff pre-installed.
podman run --rm \
-v "$SITE_COPY:/site:U" \
-i \
--cap-add=SYS_ADMIN \
--init \
ghcr.io/puppeteer/puppeteer:latest \
node -e "$(cat screenshot.js)" file:///site/_site/index.html /site/static/screenshot.png
# Resize the screenshot down and move it into the real location.
magick "$SITE_COPY/static/screenshot.png" -scale 640x360 "./static/screenshot.png"