docs icon indicating copy to clipboard operation
docs copied to clipboard

Contradictory info on `$GITHUB_OUTPUT`

Open 95-martin-orion opened this issue 1 year ago • 4 comments
trafficstars

Code of Conduct

What article on docs.github.com is affected?

Defining outputs for jobs (source) and Default environment variables (source).

What part(s) of the article would you like to see updated?

The note in this line: https://github.com/github/docs/blob/66af710ebd377e0fa0bfb7f6e8acf8747231e4aa/data/reusables/actions/jobs/section-defining-outputs-for-jobs.md?plain=1#L11

appears to contradict this entry in the table: https://github.com/github/docs/blob/66af710ebd377e0fa0bfb7f6e8acf8747231e4aa/content/actions/learn-github-actions/variables.md?plain=1#L316

Is the value of $GITHUB_OUTPUT shared between all steps, or unique to each step?

Docs Plan

Outlined in this comment.

95-martin-orion avatar Jan 22 '24 15:01 95-martin-orion

Thanks for opening this issue. A GitHub docs team member should be by to give feedback soon. In the meantime, please check out the contributing guidelines.

welcome[bot] avatar Jan 22 '24 15:01 welcome[bot]

@95-martin-orion Thank you for opening this issue! I'll get this triaged for review ✨

nguyenalex836 avatar Jan 22 '24 22:01 nguyenalex836

i want to konw, in:

jobs:
  check:
     steps:
      - name: Check for new commits
        run: |
             echo "new_commits=true" >> "$GITHUB_OUTPUT"
  build:
    needs: check
    if: ${{ needs.check.outputs.new_commits}}

I cannot correctly determine new_commits is true.

but:

    outputs:
      new_commits: ${{ steps.check.outputs.new_commits }}

  build:
    needs: check
    if: ${{ needs.check.outputs.new_commits}}

it do.

https://github.com/github/docs/blob/66af710ebd377e0fa0bfb7f6e8acf8747231e4aa/data/reusables/actions/jobs/section-defining-outputs-for-jobs.md?plain=1#L11

Is it necessary to clarify that $GITHUB_OUTPUTcannot access different jobs here? (I don't know if he can access different jobs)

RSS1102 avatar Jan 30 '24 11:01 RSS1102

Hey @95-martin-orion, thank you for opening this issue!

I definitely see where your confusion is coming from. While the contents of the output file are shared between all steps in a job, the path to the output file changes in each step. For example, on the first step the path to the output file could be /home/runner/work/_temp/_runner_file_commands/set_output_9bfa0a1d-ab75-4c96-b61f-bfccd45eeb08, and in the next step the path could be /home/runner/work/_temp/_runner_file_commands/set_output_330f510f-d204-409d-9657-49261468a340.

To make this clearer in the docs, I think we could update this line to say:

The path on the runner to the file that sets the current step's outputs from workflow commands. The path to this file is unique to the current step and changes for each step in a job. For example, /home/runner/work/_temp/_runner_file_commands/set_output_a50ef383-b063-46d9-9157-57953fc9f3f0. For more information, see "AUTOTITLE."

Instead of saying the file is unique to the current step, we'll say that the path to the file is unique to the current step.

You or anyone else is welcome to open a pull request to make these changes!

SiaraMist avatar Feb 05 '24 23:02 SiaraMist