What is a workflow_run trigger and when would you use it?
AdvancedConceptGitHub Actions
Answer
workflow_run starts a workflow when another named workflow completes (types: [completed]). It runs in the context of the default branch with access to secrets, which makes it the safe pattern for PR workflows from forks: the untrusted pull_request workflow builds and uploads an artifact with no secrets, and a privileged workflow_run workflow downloads that artifact and posts the comment or deploys.
Treat the downloaded artifact as untrusted input (never execute it or interpolate it into shell).
on:
workflow_run:
workflows: ['CI']
types: [completed]
More on GitHub Actions
What are workflows, jobs, steps and actions in GitHub Actions?BeginnerWhat events can trigger a workflow?BeginnerWhat is the difference between `pull_request` and `pull_request_target`?AdvancedWhat is a runner, and how do GitHub-hosted and self-hosted runners differ?BeginnerHow do you pass data between steps and between jobs?IntermediateHow does a build matrix work?Intermediate