GH-100 · Question #46
Which of the following are valid ways to pass data to a reusable workflow in a separate repository?
The correct answer is B. Define inputs in the reusable workflow and pass values from the calling workflow. C. Define the secrets in the caller repository and call the reusable workflow using the `secrets'. Options B and C are correct because GitHub Actions reusable workflows explicitly support two mechanisms for receiving external data: the inputs block (for non-secret data) defined under on.workflow_call.inputs, and the secrets block under on.workflow_call.secrets. For B, the…
Question
Which of the following are valid ways to pass data to a reusable workflow in a separate repository?
Options
- AUse environment variables to pass data directly to the reusable workflow.
- BDefine inputs in the reusable workflow and pass values from the calling workflow.
- CDefine the secrets in the caller repository and call the reusable workflow using the `secrets'
- DDefine the secrets in the reusable workflow's repository and reference the secret using the
How the community answered
(27 responses)- A4% (1)
- B85% (23)
- D11% (3)
Explanation
Options B and C are correct because GitHub Actions reusable workflows explicitly support two mechanisms for receiving external data: the inputs block (for non-secret data) defined under on.workflow_call.inputs, and the secrets block under on.workflow_call.secrets. For B, the calling workflow passes values using the with: keyword, matching declared inputs in the reusable workflow. For C, secrets must live in the caller's repository - the caller then forwards them to the reusable workflow using the secrets: keyword in the workflow call.
Option A is wrong because environment variables set in a calling workflow are scoped to that workflow's jobs and are not automatically inherited across repository boundaries into a reusable workflow - you must use the inputs mechanism instead. Option D is wrong because secrets defined in the reusable workflow's repository are not accessible to external callers; the secrets must exist in the caller's repository (or be inherited via secrets: inherit).
Memory tip: Think of reusable workflows like function calls - you define parameters (inputs) and protected parameters (secrets) in the function signature, and the caller supplies the values. The callee never owns the caller's secrets.
Topics
Community Discussion
No community discussion yet for this question.