Use repository_dispatch for previewing instead #13
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: PR Preview Check | |
on: | |
pull_request: | |
jobs: | |
# Deploy main repo PRs directly | |
deploy-for-main: | |
name: Trigger Preview Build and Deploy (Main Repo) | |
runs-on: ubuntu-latest | |
if: github.event.pull_request.head.repo.fork == false | |
steps: | |
- name: Trigger preview deployment | |
uses: actions/github-script@v7 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
await github.rest.repos.createDispatchEvent({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
event_type: 'pr-preview-deploy', | |
client_payload: { | |
pr_number: '${{ github.event.pull_request.number }}', | |
pr_head_sha: '${{ github.event.pull_request.head.sha }}', | |
pr_checkout_repository: '${{ github.repository }}', | |
is_fork: 'false' | |
} | |
}); | |
console.log('Triggered main repo preview deployment'); | |
# Approval gate for fork PRs | |
approve-for-fork: | |
name: Approve Fork PR | |
runs-on: ubuntu-latest | |
# if: github.event.pull_request.head.repo.fork == true | |
environment: fork-preview-protection | |
steps: | |
- run: echo "Fork PR #${{ github.event.pull_request.number }} approved for preview deployment" |