Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Contradictory info on $GITHUB_OUTPUT #31211

Closed
1 task done
95-martin-orion opened this issue Jan 22, 2024 · 4 comments · Fixed by #32703
Closed
1 task done

Contradictory info on $GITHUB_OUTPUT #31211

95-martin-orion opened this issue Jan 22, 2024 · 4 comments · Fixed by #32703
Labels
actions This issue or pull request should be reviewed by the docs actions team content This issue or pull request belongs to the Docs Content team help wanted Anyone is welcome to open a pull request to fix this issue

Comments

@95-martin-orion
Copy link

95-martin-orion commented Jan 22, 2024

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:

**Note:** `$GITHUB_OUTPUT` is shared between all steps in a job. If you use the same output name in multiple steps, the last step to write to the output will override the value. If your job uses a matrix and writes to `$GITHUB_OUTPUT`, the content will be overwritten for each matrix combination. You can use the `matrix` context to create unique output names for each job configuration. For more information, see "[AUTOTITLE](/actions/learn-github-actions/contexts#matrix-context)."

appears to contradict this entry in the table:

| `GITHUB_OUTPUT` | The path on the runner to the file that sets the current step's outputs from workflow commands. 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](/actions/using-workflows/workflow-commands-for-github-actions#setting-an-output-parameter)." |

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

Docs Plan

Outlined in this comment.

@95-martin-orion 95-martin-orion added the content This issue or pull request belongs to the Docs Content team label Jan 22, 2024
Copy link

welcome bot commented Jan 22, 2024

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.

@github-actions github-actions bot added the triage Do not begin working on this issue until triaged by the team label Jan 22, 2024
@nguyenalex836 nguyenalex836 added actions This issue or pull request should be reviewed by the docs actions team waiting for review Issue/PR is waiting for a writer's review and removed triage Do not begin working on this issue until triaged by the team labels Jan 22, 2024
@nguyenalex836
Copy link
Contributor

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

@RSS1102
Copy link

RSS1102 commented Jan 30, 2024

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.

**Note:** `$GITHUB_OUTPUT` is shared between all steps in a job. If you use the same output name in multiple steps, the last step to write to the output will override the value. If your job uses a matrix and writes to `$GITHUB_OUTPUT`, the content will be overwritten for each matrix combination. You can use the `matrix` context to create unique output names for each job configuration. For more information, see "[AUTOTITLE](/actions/learn-github-actions/contexts#matrix-context)."

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

@SiaraMist
Copy link
Contributor

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 SiaraMist added the help wanted Anyone is welcome to open a pull request to fix this issue label Feb 5, 2024
@docs-bot docs-bot added this to Help wanted in Docs open source board Feb 5, 2024
@nguyenalex836 nguyenalex836 removed the waiting for review Issue/PR is waiting for a writer's review label Mar 7, 2024
Docs open source board automation moved this from Help wanted to Done Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
actions This issue or pull request should be reviewed by the docs actions team content This issue or pull request belongs to the Docs Content team help wanted Anyone is welcome to open a pull request to fix this issue
Development

Successfully merging a pull request may close this issue.

5 participants
@95-martin-orion @RSS1102 @SiaraMist @nguyenalex836 and others