DevOpsInterviewPrep logo
← 🚀 Delivery & GitOps
Foundational

GitHub Actions job outputs and artifact identity: carry the right evidence across jobs

Map step outputs to job outputs, consume them through needs and validate missing values. Keep release identity separate from files and caches across runner boundaries.

TL;DR: A value written to GITHUB_OUTPUT belongs to a step. Expose it as a job output before another job reads it through needs. Use artifacts or a registry for release bytes, and fail when required identity metadata is absent.

A shell variable stops at its process boundary

A shell export can be useful inside one step, but another job does not inherit that process. GITHUB_ENV affects subsequent steps within a job; it is not a cross-job channel. Even when self-hosted jobs happen to land on the same machine, depending on leftover environment or workspace state makes scheduling affect correctness.

GitHub documents step-to-job output mapping. Name the producing step with id, map its output under the job's outputs, then declare the consuming job's dependency with needs.

rendering diagram…

Work a small handoff

This complete workflow uses a teaching identifier, not a real image digest. It can run manually in a disposable repository without checkout or cloud credentials.

name: output-contract
on: workflow_dispatch
permissions: {}
jobs:
  prepare:
    runs-on: ubuntu-latest
    outputs:
      candidate: ${{ steps.identity.outputs.candidate }}
    steps:
      - id: identity
        run: printf 'candidate=fixture-17\n' >> "$GITHUB_OUTPUT"
  inspect:
    needs: prepare
    runs-on: ubuntu-latest
    env:
      CANDIDATE: ${{ needs.prepare.outputs.candidate }}
    steps:
      - run: test "$CANDIDATE" = 'fixture-17'

The expected result is a successful comparison. Delete the job-level mapping and the consumer must fail because its required value is missing. Change the expected identifier and it must fail for a mismatch. Running the two shell commands locally verifies their comparison behavior, while the mapping itself requires GitHub's workflow engine.

Keep metadata and bytes separate

ChannelAppropriate payloadContract to verify
Step/job outputSmall identifier or decision valueNamed mapping and required nonempty value
Job artifactTest report or packaged filesCorrect producer, retention and content
Container registryRelease imageApproved digest and accessible manifest
Dependency cacheReusable install/build inputsSafe reuse; never sole release evidence

A consumer should download the particular producer's output, verify its expected identity and stop if the evidence is absent. Falling back to latest turns a missing output into deployment of an unreviewed candidate. Treat output values as untrusted input if upstream code is untrusted; inserting them directly into shell syntax creates a second problem. Passing them through an environment variable and quoting shell expansion avoids that particular interpolation path, but still requires value validation.

Secrets do not belong in ordinary outputs. A value may be masked or withheld, and log suppression cannot establish an authorization boundary. Obtain sensitive credentials through the intended environment or identity mechanism when the consumer is authorized to use them.

Self-check: a build prints a digest in its console, but the deploy job sees an empty needs.build.outputs.digest. What is missing? Inspect the producing step ID, GITHUB_OUTPUT write, job output mapping and dependency name. A console message is not an output declaration.

Practice the empty deploy output and connect it to artifact promotion.

RELATED CONCEPTS
PRACTICE THIS IN REAL QUESTIONS