Fork repo PRs are not deployed to GitHub Pages
This issue came up while I was reviewing one of the fork PRs (https://github.com/primer/react/pull/3634) that the forks don't get deployed to GitHub Pages.
Although the job runs successfully, it doesn't deploy the commit that comes from the pull request branch, rather it checkouts out main and deploy the last SHA of main. The reason of it does this is because on pull_request_target the ref is the PR base branch and theSHA is the last commit of the PR base branch. (docs reference). Also see this in the fork PR by visiting "Checking out the ref" section under "Checkout default branch" in the built job.
on pull_request_target the ref is the PR base branch and theSHA is the last commit of the PR base branch.
Woooow, that means it hasn't worked since we moved from vercel to github pages?! 😱
Turns out I added pull_request_target 😅 in https://github.com/primer/react/pull/2207 (Aug 2, 2022),
Right now, forks don't get deployment previews because secrets/tokens can not be shared with forks safely. However, there's an event called pull_request_target, which runs github actions on the target repo (primer/react) but runs the code from the source repo (example: user/primer-react-fork), this is the perfect solution for 99% of contributions (1% is when you are making changes to github actions workflows)
I'm not sure what the fix for this would be 😓
Suggestion from PRC planning: sounds like a fix could be similar to how we have our VRT flow set up, cc @joshblack.
From an implementation perspective, I think this could follow a similar flow to VRT where we basically build up things like storybook and the docs and pass those along to a separate workflow that runs on workflow_run. A rough sketch of this could be:
- Add a job to CI, or a separate workflow, that uploads a
github-pagesartifact withupload-artifact- Here is a similar step in vrt
- Add a
github-pagesworkflow that runs onworkflow_runafter theCIworkflow (or whatever the name is of the one created in step 1)- This workflow can add a conditional to only run if CI passes or if
github-pagesexists as an artifact - If the workflow can download github-pages, then it can use https://github.com/actions/deploy-pages to deploy it for the pull request
- This workflow can add a conditional to only run if CI passes or if
Hi! This issue has been marked as stale because it has been open with no activity for 180 days. You can comment on the issue or remove the stale label to keep it open. If you do nothing, this issue will be closed in 7 days.