-
Two days ago the Github Actions announced the deprecation of set-output and workflows started to emit these warnings:
However there is no clear documentation how to migrate the workflows and how to rewrite to use env vars - whether to use GITHUB_ENV or GITHUB_OUTPUT. I believe |
Beta Was this translation helpful? Give feedback.
Replies: 13 comments 14 replies
-
The documentation on how to set outputs now is here: https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-output-parameter You do not need to replace outputs with environment variables, just set the outputs by writing to a file instead of stdout. One thing that's missing there are multiline outputs, I found by experimenting that you can set multiline outputs using the same format as multiline environment variables. |
Beta Was this translation helpful? Give feedback.
-
Thank you for the tip. The docs are pretty vague on how this works. |
Beta Was this translation helpful? Give feedback.
-
Automatic conversion one-linerChangelog:
If you're using Bash-based workflows:sed \
-i \
'/set-output/ {
s/::set-output name=//;
s/::/=/;
s/"$/" >> $GITHUB_OUTPUT/;
}' \
.github/workflows/bash-workflows.yml Powershell-based workflows:sed \
-i \
'/set-output/ {
s/::set-output name=//;
s/::/=/;
s/"$/" >> $env:GITHUB_OUTPUT/;
}' \
.github/workflows/powershell-workflows.yml After running it, inspect the Here's an example of what it will convert: shell: bash
run: |
mkdir -p "${CCACHE_DIR}"
- echo "::set-output name=dir::$CCACHE_DIR"
- echo "::set-output name=today::$(date -I)"
- echo "::set-output name=yesterday::$(date --date=yesterday -I)"
- echo "::set-output name=name_hash::$(echo '${{ matrix.conf.name }}' | shasum | cut -b-8)"
+ echo "dir=$CCACHE_DIR" >> $GITHUB_OUTPUT
+ echo "today=$(date -I)" >> $GITHUB_OUTPUT
+ echo "yesterday=$(date --date=yesterday -I)" >> $GITHUB_OUTPUT
+ echo "name_hash=$(echo '${{ matrix.conf.name }}' | shasum | cut -b-8)" >> $GITHUB_OUTPUT |
Beta Was this translation helpful? Give feedback.
-
For what it's worth, this change materially impacts where you can set output from. Perhaps that's a good thing or design intention. Regardless, any scripts or outputs that previously ran in a Docker container will now need to volume-mount the $GITHUB_OUTPUT file (and likely will want to set it as an env var), whereas previous implementations allowed stdout to be intercepted at the top level |
Beta Was this translation helpful? Give feedback.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
-
Enviado desde mi HUAWEI P30 lite-------- Mensaje original --------De: Justin Liu ***@***.***>Fecha: mié., 19 de octubre de 2022 7:33 p. m.Para: community/community ***@***.***>CC: Subscribed ***@***.***>Asunto: Re: [community/community] set-output deprecated (Discussion #35994)
same here, thank you so much
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
same issue as @funes79 faced regarding non-replaced new line characters. any fix for this? 🙏 |
Beta Was this translation helpful? Give feedback.
-
All examples on how to use the recommended show code in either yaml or in PowerShell. What about GitHub actions written in .NET? The previous attempt (as demonstrated by the GitHub Action in .NET sample) made use of a Console.WriteLine like this:
What would the correct way be to do the same with $env.GITHUB_OUTPUT |
Beta Was this translation helpful? Give feedback.
-
Figured it out. The way to do it is:
|
Beta Was this translation helpful? Give feedback.
-
Why doesn't github just intelligently translate this on the fly? |
Beta Was this translation helpful? Give feedback.
-
Here Alternative way for use terminal or any programming language output on workflow |
Beta Was this translation helpful? Give feedback.
Automatic conversion one-liner
Changelog:
If you're using
echo "::set-output name=key::val"
syntax, this GNU sed one liner should get you most of the way:Bash-based workflows:
Powershell-based workflows:
After running it, inspect the
git diff
and make any final touches that aren't p…