What is 'GITHUB_OUTPUT' in GitHub Actions and how is it used?
Select an answer to reveal the explanation.
Short Explanation and Infographic
GITHUB_OUTPUT is how one step talks to the next. Write 'key=value' to the $GITHUB_OUTPUT file and subsequent steps can read it as '${{ steps.step-id.outputs.key }}'. It replaced the old 'set-output' command in 2022.
Full explanation below image
Full Explanation
GITHUB_OUTPUT is an environment file in GitHub Actions that steps use to share output values with subsequent steps in the same job. Usage pattern: (1) Writing to GITHUB_OUTPUT: 'echo "my_value=hello" >> $GITHUB_OUTPUT' in a shell step. (2) Reading the output: '${{ steps.step-id.outputs.my_value }}' in a later step. The 'step-id' is defined by the 'id:' field on the step that wrote the output. GITHUB_OUTPUT replaced the deprecated 'echo "::set-output name=..."' command. Multi-line values use a heredoc syntax to properly delimit the value. For passing data between jobs (not just steps), outputs must be defined at the job level and referenced with 'needs.job-id.outputs.output-name'. GITHUB_OUTPUT is reset between jobs (each job has its own environment).