Skip to content

Commit 852f6c2

Browse files
npwolfclaude
andcommitted
Merge upstream rossjrw/pr-preview-action into main
Sync with 84 upstream commits. Resolves conflict in action.yml by taking upstream's restructured architecture and re-applying our customizations (ssh-key, custom-header, custom-message-suffix). Updates generate-comment.sh to support custom-message-suffix parameter. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2 parents ac34925 + 6f3a89d commit 852f6c2

44 files changed

Lines changed: 2309 additions & 559 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
blank_issues_enabled: false
22
contact_links:
3-
- name: Start a Discussion
4-
url: https://github.com/rossjrw/pr-preview-action/discussions/new?category=q-a
5-
about: If you have a question about how to use PR Preview Action, need help with setting it up, or would like help with debugging your setup, start a new discussion.
3+
- name: Start a Discussion
4+
url: https://github.com/rossjrw/pr-preview-action/discussions/new?category=q-a
5+
about: If you have a question about how to use PR Preview Action, need help with setting it up, or would like help with debugging your setup, start a new discussion.
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
name: Create an Issue
33
about: If you have a feature request or bug report for PR Preview Action, create a new issue.
4-
title: ''
5-
labels: ''
6-
assignees: ''
4+
title: ""
5+
labels: ""
6+
assignees: ""
77
---

.github/sample-preview-link.png

73.3 KB
Loading

.github/scripts/package.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"private": true,
3+
"type": "commonjs",
4+
"devDependencies": {
5+
"image-size": "^2.0.2",
6+
"playwright": "^1.57.0"
7+
}
8+
}
Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
#!/usr/bin/env node
2+
3+
// Screenshot generator for readme
4+
5+
const { firefox } = require("playwright");
6+
const { execSync } = require("child_process");
7+
const { readFileSync } = require("fs");
8+
const { imageSize } = require("image-size");
9+
10+
async function main() {
11+
const version = execSync(
12+
'git describe --tags --match "v*.*.*" --abbrev=0',
13+
{ encoding: "utf-8" }
14+
).trim();
15+
const browser = await firefox.launch({ headless: true });
16+
const page = await browser.newPage({
17+
viewport: { width: 1280, height: 1024 },
18+
deviceScaleFactor: 2,
19+
});
20+
21+
console.log("Loading PR page...");
22+
await page.goto("https://github.com/rossjrw/pr-preview-action/pull/1", {
23+
waitUntil: "domcontentloaded",
24+
});
25+
await page.waitForTimeout(2000);
26+
console.log("Page loaded");
27+
28+
console.log("Cleaning up comment...");
29+
await page.evaluate((newVersion) => {
30+
const style = document.createElement("style");
31+
style.textContent = `
32+
.TimelineItem::before,
33+
.timeline-comment-actions,
34+
.details-overlay{
35+
display: none !important;
36+
}
37+
.timeline-comment .comment-body table {
38+
margin-bottom: 0;
39+
}
40+
.timeline-comment {
41+
max-width: fit-content;
42+
}
43+
.timeline-comment-header > * {
44+
font-size: 0 !important;
45+
}
46+
.timeline-comment-header strong {
47+
font-size: 0.875rem !important;
48+
}
49+
`;
50+
document.head.appendChild(style);
51+
52+
const links = document.querySelectorAll(
53+
'a[href="/apps/github-actions"]'
54+
);
55+
let commentGroup = null;
56+
for (const link of links) {
57+
commentGroup = link.closest(".timeline-comment-group");
58+
if (commentGroup) break;
59+
}
60+
61+
if (!commentGroup) return { error: "Comment group not found" };
62+
63+
// Replace version number
64+
let versionReplaced = 0;
65+
const walker = document.createTreeWalker(
66+
commentGroup,
67+
NodeFilter.SHOW_TEXT,
68+
null
69+
);
70+
const nodes = [];
71+
while (walker.nextNode()) {
72+
nodes.push(walker.currentNode);
73+
}
74+
nodes.forEach((node) => {
75+
if (node.textContent && node.textContent.match(/v\d+\.\d+/)) {
76+
node.textContent = node.textContent.replace(
77+
/v[\d\.\-a-z]+/g,
78+
newVersion
79+
);
80+
versionReplaced++;
81+
}
82+
});
83+
return { versionReplaced };
84+
}, version);
85+
86+
await page.waitForTimeout(500);
87+
88+
// Calculate bounding box that includes avatar and comment
89+
const bounds = await page.evaluate(() => {
90+
const links = document.querySelectorAll(
91+
'a[href="/apps/github-actions"]'
92+
);
93+
let timelineItem = null;
94+
for (const link of links) {
95+
timelineItem = link.closest(".TimelineItem");
96+
if (timelineItem) break;
97+
}
98+
99+
if (!timelineItem) return null;
100+
101+
const avatar = timelineItem.querySelector(".TimelineItem-avatar");
102+
const comment = timelineItem.querySelector(".timeline-comment");
103+
104+
if (!avatar || !comment) return null;
105+
106+
const avatarRect = avatar.getBoundingClientRect();
107+
const commentRect = comment.getBoundingClientRect();
108+
109+
return {
110+
x: Math.min(avatarRect.left, commentRect.left),
111+
y: Math.min(avatarRect.top, commentRect.top),
112+
right: Math.max(avatarRect.right, commentRect.right),
113+
bottom: Math.max(avatarRect.bottom, commentRect.bottom),
114+
};
115+
});
116+
117+
if (!bounds) {
118+
throw new Error("Could not calculate bounds");
119+
}
120+
121+
const width = bounds.right - bounds.x;
122+
const height = bounds.bottom - bounds.y;
123+
124+
console.log("Bounds:", { x: bounds.x, y: bounds.y, width, height });
125+
126+
const clipWidth = Math.round(width + 20);
127+
const clipHeight = Math.round(height + 20);
128+
129+
console.log("Taking screenshot...");
130+
await page.screenshot({
131+
path: "sample-preview-link.png",
132+
clip: {
133+
x: Math.max(0, bounds.x - 10),
134+
y: Math.max(0, bounds.y - 10),
135+
width: clipWidth,
136+
height: clipHeight,
137+
},
138+
});
139+
140+
const imageBuffer = readFileSync("sample-preview-link.png");
141+
const dimensions = imageSize(imageBuffer);
142+
console.log(
143+
`Screenshot saved to sample-preview-link.png (${dimensions.width}x${dimensions.height}px)`
144+
);
145+
146+
await browser.close();
147+
}
148+
149+
main().catch((error) => {
150+
console.error(error);
151+
process.exit(1);
152+
});
Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
name: Deploy example site
22
on:
3-
push:
4-
branches:
5-
- main
3+
push:
4+
branches:
5+
- main
66
jobs:
7-
build:
8-
runs-on: ubuntu-latest
9-
steps:
10-
- name: Checkout
11-
uses: actions/checkout@v3
12-
- name: Deploy
13-
uses: JamesIves/github-pages-deploy-action@v4
14-
with:
15-
branch: gh-pages
16-
folder: test
17-
clean-exclude: pr-preview/
7+
build:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout
11+
uses: actions/checkout@v4
12+
- name: Deploy
13+
uses: JamesIves/github-pages-deploy-action@v4
14+
with:
15+
branch: gh-pages
16+
folder: test
17+
clean-exclude: pr-preview/
Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
11
name: Preview example site
22
on:
3-
pull_request:
4-
types:
5-
- opened
6-
- reopened
7-
- synchronize
8-
- closed
3+
pull_request:
4+
types:
5+
- opened
6+
- reopened
7+
- synchronize
8+
- closed
99
concurrency: preview-${{ github.ref }}
1010
jobs:
11-
deploy-preview:
12-
runs-on: ubuntu-latest
13-
steps:
14-
- name: Checkout
15-
uses: actions/checkout@v3
11+
deploy-preview:
12+
runs-on: ubuntu-latest
13+
# Only run if this PR is not from a fork
14+
if: github.event.pull_request.head.repo.full_name == github.repository
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
1618

17-
- name: Deploy preview
18-
uses: rossjrw/pr-preview-action@v1
19-
with:
20-
source-dir: test
19+
- name: Deploy preview
20+
uses: ./
21+
with:
22+
source-dir: test/fixtures/sample

0 commit comments

Comments
 (0)