Skip to content

Auto-install Playwright when not in consumer project #105

Auto-install Playwright when not in consumer project

Auto-install Playwright when not in consumer project #105

Workflow file for this run

# GitGlimpse E2E Demo Workflow
# Runs the action against a local example app on every PR.
# Safe: no untrusted user input (PR titles/bodies) is used in run: commands.
#
# ⚠️ IMPORTANT — changes to this file only take effect after merging to main.
#
# GitHub always reads issue_comment workflows from the default branch (main),
# so edits to this file on a feature branch are silently ignored when /glimpse
# is triggered. To test a workflow change: merge to main first, then re-run.
# (Action/core code changes are fine on branches — they are rebuilt from source.)
name: GitGlimpse Demo
on:
pull_request:
types: [opened, synchronize]
issue_comment:
types: [created]
jobs:
demo:
runs-on: ubuntu-latest
# Run on PR events, or on issue_comment only if it's a PR comment containing /glimpse
if: >-
github.event_name == 'pull_request' ||
(github.event_name == 'issue_comment' &&
github.event.issue.pull_request != null &&
contains(github.event.comment.body, '/glimpse'))
permissions:
pull-requests: write
contents: write
issues: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event_name == 'issue_comment' && format('refs/pull/{0}/head', github.event.issue.number) || '' }}
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'pnpm'
- name: Install dependencies
run: pnpm install
# Always build from source so the action dist matches the checked-out code.
# This ensures /glimpse on a PR branch uses that branch's action/core code,
# not whatever was last committed to dist or published to main.
- name: Build action from source
run: pnpm build
# Check whether the pipeline should run before installing heavy dependencies.
# Subsequent steps are gated on this output to skip ffmpeg/Playwright when
# the trigger config (on-demand, smart, etc.) decides to skip the run.
- uses: ./check-trigger
id: check
with:
config-path: examples/simple-app/git-glimpse.config.ts
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Install FFmpeg
if: steps.check.outputs.should-run == 'true'
run: sudo apt-get install -y ffmpeg
- name: Cache Playwright browsers
if: steps.check.outputs.should-run == 'true'
uses: actions/cache@v4
with:
path: ~/.cache/ms-playwright
key: playwright-chromium-${{ hashFiles('pnpm-lock.yaml') }}
restore-keys: playwright-chromium-
- name: Install Playwright Chromium
if: steps.check.outputs.should-run == 'true'
run: pnpm --filter @git-glimpse/core exec playwright install chromium --with-deps
- name: Start example app
if: steps.check.outputs.should-run == 'true'
run: node examples/simple-app/server.js &
- name: Wait for app to be ready
if: steps.check.outputs.should-run == 'true'
run: |
for i in $(seq 1 15); do
curl -sf http://localhost:3000 && echo "App ready" && exit 0
echo "Waiting... ($i)"
sleep 1
done
echo "App did not become ready" && exit 1
- uses: ./packages/action
if: steps.check.outputs.should-run == 'true'
with:
preview-url: 'http://localhost:3000'
config-path: examples/simple-app/git-glimpse.config.ts
env:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: React with hooray on success
if: >-
github.event_name == 'issue_comment' &&
steps.check.outputs.should-run == 'true' &&
success()
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh api repos/$GITHUB_REPOSITORY/issues/comments/${{ github.event.comment.id }}/reactions \
--method POST --field content=hooray || true
- name: React with confused on failure
if: >-
github.event_name == 'issue_comment' &&
failure()
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh api repos/$GITHUB_REPOSITORY/issues/comments/${{ github.event.comment.id }}/reactions \
--method POST --field content=confused || true