Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use
pull_request_target
for PR preview teardown (Qiskit#1512)
Should fix 1034. ## Investigation It seems PR previews _are_ being cleaned up correctly for _merged_ PRs; the teardown action is running, and the previews are no longer accessible after merging (see following screenshot as example). <img width="300" alt="Screenshot 2024-06-07 at 13 35 48" src="https://github.com/Qiskit/documentation/assets/36071638/0066b309-9432-4213-81bd-1836521a8900"> It seems the problem is if a PR is closed but not merged (e.g. Qiskit#1468, Qiskit#1380, and Qiskit#1289 still have active previews). I believe this is the reason: https://github.com/orgs/community/discussions/26657#discussioncomment-3252753. ## Solution This PR tries to fix this by using the `pull_request_target` event to trigger teardowns. This should trigger correctly when PRs are closed. We need to be careful with this event as it allows untrusted PRs to trigger events using secrets. Since this action runs on the target branch (rather than a merge commit of the target and PR branches), an untrusted user shouldn't be able to do anything malicious, but we need to make sure we **never** checkout the PR branch with this event type, or read any user-defined inputs (such as the PR title) as it could lead to an injection. I think this is unlikely, but I've left a warning in the action just in case. See #7 for a demonstration. The "Preview teardown" step ran after the PR was closed.
- Loading branch information