-
Notifications
You must be signed in to change notification settings - Fork 5
67 lines (54 loc) · 2.03 KB
/
Copy pathbuild-gallery.yml
File metadata and controls
67 lines (54 loc) · 2.03 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# .github/workflows/build-gallery.yml
#
# Auto-generate the example gallery (index.html) on push to main.
# The generated file is committed back to the branch, and GitHub Pages
# serves it via the normal "Deploy from a branch" setting.
name: Build Gallery
on:
push:
branches: [main]
workflow_dispatch:
permissions:
contents: write # needed to push the generated index.html back
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: "20"
cache: npm
- name: Install Node dependencies
run: npm ci
- name: Install ffmpeg
run: sudo apt-get update && sudo apt-get install -y ffmpeg
# Cache Playwright's bundled Chromium across runs, keyed on the lockfile
# (which pins the Playwright version).
- name: Cache Playwright browsers
uses: actions/cache@v4
with:
path: ~/.cache/ms-playwright
key: playwright-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
- name: Install Playwright Chromium
run: npx playwright install --with-deps chromium
# Regenerate thumbnails (animated WebP + poster). The script content-hashes
# each example and skips unchanged ones, so this is cheap when nothing
# changed — only edited examples are re-captured.
- name: Generate previews
run: node scripts/capture_previews.mjs
- name: Generate gallery index.html
run: python scripts/build_gallery.py
- name: Commit and push if changed
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add index.html previews
git diff --cached --quiet || git commit -m "Auto-generate gallery + previews [skip ci]"
git push