Skip to content

heredoc example is wrong #17261

@davidmaxwaterman

Description

@davidmaxwaterman

Code of Conduct

What article on docs.github.com is affected?

https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#example-2

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

      echo 'JSON_RESPONSE<<EOF' >> $GITHUB_ENV
      curl https://example.lab >> $GITHUB_ENV
      echo 'EOF' >> $GITHUB_ENV

It doesn't seem to work. IINM, it's missing an = and the technique is flawed anyway (setting an env doesn't read from stdin, nor a heredoc).

It should be something like the following - cat reads from stdin/heredoc, and it needs to be executed in a subshell, hence $():

      echo 'JSON_RESPONSE=$(cat <<EOF' >> $GITHUB_ENV
      curl https://example.lab >> $GITHUB_ENV
      echo 'EOF' >> $GITHUB_ENV
      echo ')' >> $GITHUB_ENV

The poweshell example might well need some similar TLC (I have no experience of powershell, but it seems like it uses some kind of @'....'@ syntax.

Ref:
https://stackoverflow.com/questions/1167746/how-to-assign-a-heredoc-value-to-a-variable-in-bash#answer-1167849
https://4sysops.com/archives/the-powershell-here-string-preserve-text-formatting/

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    SME staleThe request for an SME has staledactionsThis issue or pull request should be reviewed by the docs actions teamcontentThis issue or pull request belongs to the Docs Content teamneeds SMEThis proposal needs review from a subject matter expertwaiting for reviewIssue/PR is waiting for a writer's review

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions