Skip to content
This repository was archived by the owner on Jan 28, 2026. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
7d04f7d
Create screenshot-on-pr.yml
amarilda611 May 29, 2025
905ea34
Create screenshot.js
amarilda611 May 29, 2025
63889f4
Update screenshot-on-pr.yml
amarilda611 May 29, 2025
e9eefb3
Update screenshot-on-pr.yml
amarilda611 May 29, 2025
5d6888d
Update screenshot-on-pr.yml
amarilda611 May 29, 2025
ec21c34
Update screenshot.js
amarilda611 May 29, 2025
1a65cb1
Update screenshot-on-pr.yml
amarilda611 May 29, 2025
3b3c88e
Update screenshot-on-pr.yml
amarilda611 May 29, 2025
6417bc4
Update screenshot.js
amarilda611 May 29, 2025
31ae72b
Update screenshot.js
amarilda611 May 29, 2025
7f16749
Update screenshot-on-pr.yml
amarilda611 May 29, 2025
39e4fb1
Update screenshot.js
amarilda611 May 29, 2025
a56a3ab
Update screenshot-on-pr.yml
amarilda611 May 29, 2025
edefe7b
Update screenshot.js
amarilda611 May 29, 2025
a202684
Update screenshot-on-pr.yml
amarilda611 May 29, 2025
96305e6
Update screenshot.js
amarilda611 May 29, 2025
cf62c61
Update screenshot-on-pr.yml
amarilda611 May 29, 2025
bc9fddb
Update screenshot.js
amarilda611 May 29, 2025
ace0b77
Update screenshot-on-pr.yml
amarilda611 May 29, 2025
9571ef0
Update screenshot.js
amarilda611 May 29, 2025
20585b1
Update screenshot-on-pr.yml
amarilda611 May 29, 2025
d621a5d
Update screenshot.js
amarilda611 May 29, 2025
1c554c8
Update screenshot-on-pr.yml
amarilda611 May 29, 2025
96339ab
Update screenshot.js
amarilda611 May 29, 2025
11a009e
Update screenshot-on-pr.yml
amarilda611 May 29, 2025
4346c3d
Update screenshot.js
amarilda611 May 29, 2025
fb094a9
Update screenshot-on-pr.yml
amarilda611 May 29, 2025
3287807
Update screenshot.js
amarilda611 May 29, 2025
edc849d
Update screenshot-on-pr.yml
amarilda611 May 29, 2025
79b94cd
Update screenshot.js
amarilda611 May 29, 2025
1518ae1
Update screenshot-on-pr.yml
amarilda611 May 29, 2025
4bfe625
Update screenshot.js
amarilda611 May 29, 2025
892d49f
Update screenshot-on-pr.yml
amarilda611 May 29, 2025
bd4d4ff
Update screenshot.js
amarilda611 May 29, 2025
e6570eb
Update screenshot.js
amarilda611 May 29, 2025
cf992cf
Update screenshot-on-pr.yml
amarilda611 May 29, 2025
f2d64e7
Update screenshot.js
amarilda611 May 29, 2025
5930382
Update screenshot-on-pr.yml
amarilda611 May 29, 2025
1b97bb6
Update screenshot.js
amarilda611 May 29, 2025
a62b880
Update screenshot-on-pr.yml
amarilda611 May 29, 2025
17102b8
Update screenshot.js
amarilda611 May 29, 2025
c0a14df
Update screenshot-on-pr.yml
amarilda611 May 29, 2025
9a94ddf
Update screenshot.js
amarilda611 May 29, 2025
3b66f9b
Update screenshot-on-pr.yml
amarilda611 May 29, 2025
8fa3703
Update screenshot.js
amarilda611 May 29, 2025
a4f3527
Update screenshot-on-pr.yml
amarilda611 May 29, 2025
0e32018
Update screenshot.js
amarilda611 May 29, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions .github/workflows/screenshot-on-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: GUI Screenshots in PR

on:
pull_request:
types: [opened, reopened, synchronize]

permissions:
pull-requests: write

jobs:
capture-screenshots:
runs-on: ubuntu-latest
timeout-minutes: 3

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Install Playwright
run: |
npm install playwright
npx playwright install chromium # Fix: Install Chromium explicitly

- name: Create screenshots directory
run: mkdir -p screenshots

- name: Capture screenshots
run: node scripts/screenshot.js

- name: Generate base64 images
id: screenshots
run: |
IMAGES_MARKDOWN=""
for file in screenshots/*.jpg; do
[ -e "$file" ] || continue
base64_data=$(base64 -w0 "$file")
IMAGES_MARKDOWN+="![${file##*/}](data:image/jpeg;base64,$base64_data)\n\n"
done
# Escape newlines for GitHub output
IMAGES_MARKDOWN="${IMAGES_MARKDOWN//$'\n'/'%0A'}"
echo "images=$IMAGES_MARKDOWN" >> $GITHUB_OUTPUT

- name: Post images to PR
uses: marocchino/sticky-pull-request-comment@v2
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
header: gui-screenshots
message: |
## 🖼️ Automated UI Preview
${{ steps.screenshots.outputs.images }}
46 changes: 46 additions & 0 deletions scripts/screenshot.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
const { chromium } = require('playwright');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[prettier] reported by reviewdog 🐶

Suggested change
const { chromium } = require('playwright');
const { chromium } = require("playwright");


(async () => {
let browser;
try {
// Launch Chromium (explicitly specify)
browser = await chromium.launch({
channel: 'chromium',
headless: true
Comment on lines +7 to +9
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[prettier] reported by reviewdog 🐶

Suggested change
browser = await chromium.launch({
channel: 'chromium',
headless: true
browser = await chromium.launch({
channel: "chromium",
headless: true,

});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[prettier] reported by reviewdog 🐶

Suggested change

const page = await browser.newPage();
await page.setViewportSize({ width: 800, height: 600 });

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[prettier] reported by reviewdog 🐶

Suggested change

// Capture homepage
await page.goto('https://example.com', {
waitUntil: 'networkidle',
timeout: 60000
Comment on lines +16 to +18
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[prettier] reported by reviewdog 🐶

Suggested change
await page.goto('https://example.com', {
waitUntil: 'networkidle',
timeout: 60000
await page.goto("https://example.com", {
waitUntil: "networkidle",
timeout: 60000,

});
await page.screenshot({
path: 'screenshots/home.jpg',
type: 'jpeg',
quality: 70
Comment on lines +20 to +23
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[prettier] reported by reviewdog 🐶

Suggested change
await page.screenshot({
path: 'screenshots/home.jpg',
type: 'jpeg',
quality: 70
await page.screenshot({
path: "screenshots/home.jpg",
type: "jpeg",
quality: 70,

});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[prettier] reported by reviewdog 🐶

Suggested change

// Capture about page
await page.goto('https://example.com/about', {
waitUntil: 'networkidle',
timeout: 60000
Comment on lines +27 to +29
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[prettier] reported by reviewdog 🐶

Suggested change
await page.goto('https://example.com/about', {
waitUntil: 'networkidle',
timeout: 60000
await page.goto("https://example.com/about", {
waitUntil: "networkidle",
timeout: 60000,

});
await page.screenshot({
path: 'screenshots/about.jpg',
type: 'jpeg',
quality: 70
Comment on lines +31 to +34
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[prettier] reported by reviewdog 🐶

Suggested change
await page.screenshot({
path: 'screenshots/about.jpg',
type: 'jpeg',
quality: 70
await page.screenshot({
path: "screenshots/about.jpg",
type: "jpeg",
quality: 70,

});

console.log('✅ Screenshots captured successfully!');
Comment on lines +36 to +37
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[prettier] reported by reviewdog 🐶

Suggested change
console.log('✅ Screenshots captured successfully!');
console.log("✅ Screenshots captured successfully!");

} catch (error) {
console.error('❌ Screenshot failed:', error);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[prettier] reported by reviewdog 🐶

Suggested change
console.error('❌ Screenshot failed:', error);
console.error("❌ Screenshot failed:", error);

process.exit(1);
} finally {
if (browser) {
await browser.close();
}
}
})();