Skip to content

Add push trigger for main branch in capture workflow #32

Add push trigger for main branch in capture workflow

Add push trigger for main branch in capture workflow #32

Workflow file for this run

name: Slide Deck Screenshots
on:
push:
branches:
- main
workflow_dispatch:
inputs:
zoom_level:
description: Zoom level for screenshot capture windows
required: false
default: '1'
type: choice
options:
- '0.5'
- '0.75'
- '1'
- '1.25'
- '1.5'
- '2'
num_workers:
description: Number of Chromium workers to run in parallel
required: false
default: '8'
type: choice
options:
- '1'
- '2'
- '4'
- '6'
- '8'
permissions:
contents: write
jobs:
screenshot:
runs-on: blacksmith-8vcpu-ubuntu-2404
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Install Playwright system deps (local only)
if: runner.environment != 'github-hosted'
run: |
sudo apt-get update -qq
sudo apt-get install -y --no-install-recommends \
ca-certificates libnss3 libnspr4 libatk1.0-0 libatk-bridge2.0-0 \
libcups2 libdrm2 libxkbcommon0 libxcomposite1 libxdamage1 \
libxrandr2 libgbm1 libpango-1.0-0 libpangocairo-1.0-0 \
libatspi2.0-0 libxfixes3 libasound2t64 unzip
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Install Playwright
run: |
bun add -d playwright
bunx playwright install chromium
- name: Start server and take screenshots
env:
SCREENSHOT_ZOOM_LEVEL: ${{ inputs.zoom_level || '1' }}
SCREENSHOT_NUM_WORKERS: ${{ inputs.num_workers || '4' }}
SCREENSHOT_OUT_DIR: ${{ github.workspace }}/.screenshots
run: |
./scripts/capture-screenshots.sh
- name: Create orphan branch and commit screenshots
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
FOLDERS=$(bun -e "console.log(JSON.parse(require('fs').readFileSync('.screenshots/_screenshot_folders.json', 'utf8')).join(' '))")
rm .screenshots/_screenshot_folders.json
cp .screenshots/view.html /tmp/view.html
mv .screenshots/slide-* /tmp/
cp index.html /tmp/index.html
cp present.md /tmp/present.md
cp custom.css /tmp/custom.css
cp -r vendor /tmp/vendor
git checkout main || git checkout master || true
git branch -D screenshots 2>/dev/null || true
git checkout --orphan screenshots
git rm -rf . 2>/dev/null || true
rm -rf node_modules
for f in $FOLDERS; do
cp -r /tmp/$f .
done
cp /tmp/view.html view.html
cp /tmp/index.html index.html
cp /tmp/present.md present.md
cp /tmp/custom.css custom.css
cp -r /tmp/vendor vendor
cat > README.md << 'README_EOF'
# Screenshot Branch
Automated screenshots of the slide deck for visual regression testing.
## Directories
Each directory corresponds to a slide or basement slide (slide-%02d format):
- **slide-01** through **slide-17** : Main horizontal slides
- **slide-08-02** : Basement slide under slide 8
- **slide-16-02**, **slide-16-03** : Basement slides under slide 16
Each directory contains screenshots at various resolutions.
README_EOF
git add slide-*/ view.html index.html present.md custom.css vendor README.md
git commit -m "Update slide deck screenshots [skip ci]"
git push origin screenshots --force
echo "Done! Screenshots pushed to screenshots branch."