-
Notifications
You must be signed in to change notification settings - Fork 0
101 lines (87 loc) · 3.19 KB
/
Copy pathdemo-assets.yml
File metadata and controls
101 lines (87 loc) · 3.19 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
name: Verified Demo Assets
on:
pull_request:
paths:
- "examples/safe-agent-api/**"
- ".github/scripts/capture-demo.mjs"
- ".github/scripts/build-demo-gif.py"
- ".github/workflows/demo-assets.yml"
workflow_dispatch:
permissions:
contents: write
jobs:
capture:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout source branch
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref || github.ref_name }}
- name: Setup Python
uses: actions/setup-python@v7
with:
python-version: "3.12"
cache: pip
cache-dependency-path: examples/safe-agent-api/pyproject.toml
- name: Install Safe Agent API and image tools
run: |
python -m pip install -e "examples/safe-agent-api[dev]"
python -m pip install Pillow==11.3.0
- name: Start Safe Agent API
run: |
cd examples/safe-agent-api
fastapi run app/main.py --host 127.0.0.1 --port 8000 > /tmp/safe-agent-api.log 2>&1 &
echo $! > /tmp/safe-agent-api.pid
for attempt in {1..30}; do
if curl --fail --silent http://127.0.0.1:8000/health >/dev/null; then
exit 0
fi
sleep 1
done
cat /tmp/safe-agent-api.log
exit 1
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: "22"
- name: Install Playwright Chromium
run: |
npm install --no-save playwright@1.55.0
npx playwright install --with-deps chromium
- name: Capture real Playground frames
run: node .github/scripts/capture-demo.mjs | tee /tmp/demo-capture.log
- name: Build optimized GIF from verified frames
run: python .github/scripts/build-demo-gif.py
- name: Validate and report asset sizes
run: |
test -s assets/demo/safe-agent-playground.png
test -s assets/demo/safe-agent-demo.gif
ls -lh assets/demo/safe-agent-playground.png assets/demo/safe-agent-demo.gif
- name: Upload verified assets
uses: actions/upload-artifact@v4
with:
name: safe-agent-demo-assets
path: |
assets/demo/safe-agent-playground.png
assets/demo/safe-agent-demo.gif
if-no-files-found: error
retention-days: 14
- name: Commit verified assets to source branch
if: >-
github.event_name == 'pull_request' &&
github.event.pull_request.head.repo.full_name == github.repository &&
github.actor != 'github-actions[bot]'
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add assets/demo/safe-agent-playground.png assets/demo/safe-agent-demo.gif
if git diff --cached --quiet; then
echo "Verified assets are unchanged."
exit 0
fi
git commit -m "docs: refresh verified demo assets"
git push origin "HEAD:${GITHUB_HEAD_REF}"
- name: Show API logs on failure
if: failure()
run: cat /tmp/safe-agent-api.log || true