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

ci: replace GITHUB_OUTPUT with GITHUB_ENV for multiline variables #18857

Merged
merged 1 commit into from
Nov 2, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,15 @@ jobs:
# The sed removes carriage returns so that the body is easier to parse later, and
# escapes backticks so that they are not executed as commands.
PR_BODY=$(printf '%s' "$PR" | jq '.[0].body' | sed 's/\\r//g' | sed 's/`/\\`/g')
echo pr_body=${PR_BODY} >> $GITHUB_OUTPUT
echo "pr_body<<EOF" >> $GITHUB_ENV
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did changing from output to env fix this, or is this just what the practice is supposed to be?

I thought they were the same place

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Official documentation mentions multiline strings only with $GITHUB_ENV. I assume it's the desired way to pass multiline strings through the pipeline.
https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#multiline-strings

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And yeah, both $GITHUB_OUTPUT and $GITHUB_ENV are paths to some magic files, but it's different files.

echo "$PR_BODY" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: Extract Changelog
id: extract_changelog
shell: bash
run: |-
set -x
PR_BODY=${{ steps.fetch_pr_body.outputs.pr_body}}
PR_BODY=${{ env.pr_body}}
if [[ $PR_BODY = "null" ]]; then
echo "No PR body exists for this commit, so a release cannot be generated."
exit 1
Expand Down