Interview Prep/CI/CD/GitHub Actions

A PR from a fork needs to run tests but must not get repo secrets. How do you set up triggers?

IntermediateScenarioGitHub Actions
Answer

Situation read → pull_request vs pull_request_target.

What I'd do →

  1. Use pull_request for tests: forks get a read-only token and no secrets.
  2. If you must comment on the PR, use a second workflow on workflow_run that reads artifacts produced by the first, and treat them as untrusted data.
  3. Never check out and run PR head code in a pull_request_target workflow.

Why → pull_request_target runs with secrets and a write token on the base repo; running fork code there is a known compromise path.

Interview tip → Two-workflow pattern for fork comments.

All CI/CD questions

More on GitHub Actions