Skip to content

Refactor PR preview workflow for improved approval process #1370

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 27, 2025

Conversation

st0012
Copy link
Member

@st0012 st0012 commented May 14, 2025

Because GitHub Actions' manual dispatching doesn't allow pre-filling the PR number, it'd be tedious for maintainers to manually trigger the workflow.

This refactor introduces a new workflow that checks for PRs from the main repository or forks, and if it's a fork, it requires approval to deploy. This works by associating the workflow with an environment that requires approval to deploy.

The pr-review-check.yml workflow will then call the cloudflare-preview.yml workflow to build and deploy the preview.

Copy link

cloudflare-workers-and-pages bot commented May 14, 2025

Deploying rdoc with  Cloudflare Pages  Cloudflare Pages

Latest commit: 610ac87
Status: ✅  Deploy successful!
Preview URL: https://297db41c.rdoc-6cd.pages.dev
Branch Preview URL: https://improve-preview-building-wor.rdoc-6cd.pages.dev

View logs

@st0012 st0012 force-pushed the improve-preview-building-workflows branch 5 times, most recently from cad758f to d2cb4c7 Compare May 14, 2025 22:01
Copy link

github-actions bot commented May 14, 2025

🚀 Preview deployment available at: https://52432c94.rdoc-6cd.pages.dev (commit: 610ac87)

@st0012 st0012 force-pushed the improve-preview-building-workflows branch from d2cb4c7 to 2cca158 Compare June 27, 2025 20:40
@st0012 st0012 marked this pull request as ready for review June 27, 2025 20:42
Because GitHub Actions' manual dispatching doesn't allow pre-filling the
PR number, it'd be tedious for maintainers to manually trigger the workflow.

This refactor introduces a new workflow that checks for PRs from the main
repository or forks, and if it's a fork, it requires approval to deploy.
This works by associating the workflow with an environment that requires
approval to deploy.

The pr-review-check.yml workflow will then call the cloudflare-preview.yml
workflow to build and deploy the preview.
@st0012 st0012 force-pushed the improve-preview-building-workflows branch from 2cca158 to af6ac77 Compare June 27, 2025 20:45
@st0012 st0012 merged commit 552d1c4 into master Jun 27, 2025
56 of 64 checks passed
@st0012 st0012 deleted the improve-preview-building-workflows branch June 27, 2025 21:03
st0012 added a commit that referenced this pull request Jun 27, 2025
After testing, #1370 doesn't work for forks as the
`trigger-fork-preview` is run on the fork repo, not on the main repo,
the secrets actually aren't available. So I'm changing the flows to the
below:

### Main Repository PR Flow
```mermaid
graph LR
    A[PR Opened<br/>from main repo] --> B[pr-preview-check.yml<br/>deploy-main-repo job]
    B --> C[Dispatch Event<br/>with GITHUB_TOKEN]
    C --> D[cloudflare-preview.yml<br/>receives dispatch]
    D --> E[Deploy with<br/>Repository Secrets]
```

### Fork PR Flow

```mermaid
graph LR
    A[PR Opened<br/>from fork] --> B[pr-preview-check.yml<br/>approve-fork job]
    B --> D[Manual Approval<br/>Required]
    D --> F[fork-preview-deploy.yml<br/>triggered by workflow_run and dispatches event]
    F --> G[cloudflare-preview.yml<br/>receives dispatch]
    G --> H[Deploy with<br/>Repository Secrets]
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant