Add a new workflow to deploy page preview for PRs from forks #1
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Comment on Fork PRs | |
| on: | |
| pull_request: | |
| types: [opened, reopened, synchronize] | |
| jobs: | |
| comment-on-fork-pr: | |
| runs-on: ubuntu-latest | |
| # Only run for fork PRs | |
| if: github.event.pull_request.head.repo.fork == true | |
| steps: | |
| - name: Comment on PR with manual deployment instructions | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const prNumber = context.payload.pull_request.number; | |
| const workflowUrl = `https://github.com/ruby/rdoc/actions/workflows/cloudflare-preview.yml`; | |
| const branch = context.payload.pull_request.head.ref; | |
| // Create a direct link that pre-fills the PR number input | |
| const dispatchUrl = `${workflowUrl}/dispatch?ref=main&inputs%5Bpull_request_number%5D=${prNumber}`; | |
| await github.rest.issues.createComment({ | |
| issue_number: prNumber, | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| body: `## Cloudflare Preview Deployment | |
| ⚠️ This PR is from a fork, so the preview deployment workflow doesn't run automatically for security reasons. | |
| If you're a maintainer and want to preview this PR: | |
| [➡️ Click here to run the workflow with PR #${prNumber} pre-filled](${dispatchUrl}) | |
| This will trigger a Cloudflare Pages preview deployment for this PR.` | |
| }); |