When should you use `workflow_run`, and what is its security trap?
AdvancedConceptTriggers & Events
Answer
workflow_run starts a workflow when another workflow completes, in the base repo's privileged context. The common safe pattern: an unprivileged pull_request workflow builds and uploads results as an artifact, and a privileged workflow_run workflow posts the PR comment.
on:
workflow_run:
workflows: ["CI"]
types: [completed]
Trap: the artifact is attacker-controlled. Downloading it and executing it, or source-ing values from it into scripts, or extracting it into the workspace over trusted files, is a pwn request. Treat artifact content as data, validate it (for example, a PR number must be an integer), and never run it.
More on Triggers & Events
How do you trigger a workflow on pushes to `main` and on PRs that target `main`?BeginnerWhat activity types does `pull_request` trigger on by default, and how do you add more?IntermediateHow do `branches` and `branches-ignore` filters work with globs?BeginnerHow do path filters work, and what are their limits?AdvancedHow do you trigger only on version tags, and what is the gotcha with pushing many tags?IntermediateWhat is `workflow_dispatch`, and what input types does it support?Beginner