Skip to content

Commit 27d1b05

Browse files
committed
Add workflow to comment on fork PRs
The comment should allow maintainers to trigger a preview deployment for fork PRs more easily.
1 parent 1a957ef commit 27d1b05

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Comment on Fork PRs
2+
3+
on:
4+
pull_request:
5+
types: [opened, reopened, synchronize]
6+
7+
jobs:
8+
comment-on-fork-pr:
9+
runs-on: ubuntu-latest
10+
# Only run for fork PRs
11+
if: github.event.pull_request.head.repo.fork == true
12+
steps:
13+
- name: Comment on PR with manual deployment instructions
14+
uses: actions/github-script@v7
15+
with:
16+
script: |
17+
const prNumber = context.payload.pull_request.number;
18+
const workflowUrl = `https://github.com/ruby/rdoc/actions/workflows/cloudflare-preview.yml`;
19+
const branch = context.payload.pull_request.head.ref;
20+
21+
// Create a direct link that pre-fills the PR number input
22+
const dispatchUrl = `${workflowUrl}/dispatch?ref=main&inputs%5Bpull_request_number%5D=${prNumber}`;
23+
24+
await github.rest.issues.createComment({
25+
issue_number: prNumber,
26+
owner: context.repo.owner,
27+
repo: context.repo.repo,
28+
body: `## Cloudflare Preview Deployment
29+
30+
⚠️ This PR is from a fork, so the preview deployment workflow doesn't run automatically for security reasons.
31+
32+
If you're a maintainer and want to preview this PR:
33+
34+
[➡️ Click here to run the workflow with PR #${prNumber} pre-filled](${dispatchUrl})
35+
36+
This will trigger a Cloudflare Pages preview deployment for this PR.`
37+
});

0 commit comments

Comments
 (0)