GH-200 - Author and manage workflows - Section 1.7

Manage caching and artifacts and pass data between jobs and steps using GITHUB_ENV, GITHUB_OUTPUT, artifacts and reusable workflow outputs.

Cache dependency directories with actions/cache and upload and download build artifacts to share files across jobs. Pass step-level outputs via GITHUB_OUTPUT and job-level environment mutations via GITHUB_ENV.

actions/cacheartifactsGITHUB_OUTPUTGITHUB_ENV

Practice question for this objective

Free sampleAuthor and manage workflowsmedium

A reusable workflow called through workflow_call computes a build identifier and must return it to the caller so the caller can reference it as needs.call-build.outputs.build_id. The reusable file already sets a job output. What else must the reusable workflow declare for the value to reach the caller?

on:
  workflow_call:
    outputs:
      build_id:
        value: ${{ jobs.compute.outputs.build_id }}
  • ADeclare an output under on.workflow_call.outputs whose value maps to the job output, because a reusable workflow only returns values that are mapped through its workflow_call outputs block. Correct
  • BNothing further, because once a job inside the reusable workflow sets a job output, the caller can read it directly as needs.call-build.outputs.build_id without any on.workflow_call declaration.
  • CUpload the build identifier as an artifact in the reusable workflow, because the caller automatically downloads artifacts produced by a called workflow and reads them as job outputs.
  • DWrite the build identifier to the GITHUB_ENV file in the reusable workflow, because env values set there are inherited by the calling workflow and exposed under the called job's outputs.
Return data from a reusable workflow by mapping a job output through an on.workflow_call.outputs entry so the caller reads it via needs. A reusable workflow does not expose its internal job outputs automatically. It must declare each return value under on.workflow_call.outputs, setting that output's value to the relevant job output expression such as jobs.compute.outputs.build_id. Only then does the calling workflow read the value through the needs context of the job that called it. Artifacts and GITHUB_ENV do not bridge to the caller as outputs.

Why A is correct: A reusable workflow returns data only through an on.workflow_call.outputs entry whose value references the producing job output, so mapping build_id there lets the caller read needs.call-build.outputs.build_id.

Why B is wrong: Tempting because the job output exists, but a reusable workflow only exposes values the caller can read when they are declared under on.workflow_call.outputs, so the caller would otherwise see nothing.

Why C is wrong: Tempting because artifacts share data, but they are downloaded explicitly and are not surfaced as outputs, so an artifact cannot populate needs.call-build.outputs.build_id for the caller.

Why D is wrong: Tempting because GITHUB_ENV sets values, but those stay inside the job that wrote them and are never inherited by the caller, so they cannot become a reusable workflow output.

See more GH-200 practice questions, answers explained.

More in this domain

Back to all Author and manage workflows objectives, or the GH-200 cert hub.

Examworthy is not affiliated with or endorsed by GitHub. Original, blueprint-aligned practice material only.