-
Notifications
You must be signed in to change notification settings - Fork 0
123 lines (107 loc) · 4.36 KB
/
demo.yml
File metadata and controls
123 lines (107 loc) · 4.36 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# 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