-
Notifications
You must be signed in to change notification settings - Fork 457
42 lines (38 loc) · 1.68 KB
/
pr-preview-check.yml
File metadata and controls
42 lines (38 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
name: PR Preview Check and Trigger
on:
pull_request:
jobs:
# For PRs from the main repo - direct call to the shared workflow
trigger-main-repo-preview:
name: Trigger Preview (Main Repo)
uses: ./.github/workflows/cloudflare-preview.yml
if: github.event.pull_request.head.repo.fork == false
with:
pr_number: ${{ github.event.pull_request.number }}
pr_head_sha: ${{ github.event.pull_request.head.sha }}
pr_checkout_repository: ${{ github.repository }}
secrets:
cloudflare_api_token: ${{ secrets.CLOUDFLARE_API_TOKEN }}
cloudflare_account_id: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
# For fork PRs - this job requires approval
wait-for-approval:
name: Wait for Approval (Fork PR)
runs-on: ubuntu-latest
if: github.event.pull_request.head.repo.fork == true
environment: fork-preview-protection
# This job only serves as an approval gate - it doesn't do anything else
steps:
- run: echo "Approval granted. Proceeding with preview deployment for commit ${{ github.event.pull_request.head.sha }}."
# Once approval is granted, call the shared workflow
trigger-fork-preview:
name: Trigger Preview (Fork - After Approval)
needs: wait-for-approval
uses: ./.github/workflows/cloudflare-preview.yml
if: github.event.pull_request.head.repo.fork == true
with:
pr_number: ${{ github.event.pull_request.number }}
pr_head_sha: ${{ github.event.pull_request.head.sha }}
pr_checkout_repository: ${{ github.event.pull_request.head.repo.full_name }}
secrets:
cloudflare_api_token: ${{ secrets.CLOUDFLARE_API_TOKEN_FOR_FORKS }}
cloudflare_account_id: ${{ secrets.CLOUDFLARE_ACCOUNT_ID_FOR_FORKS }}