Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

How to use multiline variable in a script#458

Unanswered
baxelrod-bdai asked this question inQ&A
Discussion options

I am having trouble using a multiline variable in thescript part of actionactions/github-script@v6.

I found out how to convert it to a one line string, and this works fine in therun part of a second step. For example, this works:

    steps:    - name: Step1      id: stepone      run: |        long_test_string="line one          line two          line three"        echo "Long test string:"        echo $long_test_string        LONG2=${long_test_string}        LONG2="${LONG2//'%'/'%25'}"        LONG2="${LONG2//$'\n'/'%0A'}"        LONG2="${LONG2//$'\r'/'%0D'}"        echo "long2=$LONG2" >> "$GITHUB_OUTPUT"           - name: Step2      run: |        echo "${{ steps.stepone.outputs.long2 }}"

However, when I try to display this in a PR comment, I get an error.

    - name: Step3      uses: actions/github-script@v6      with:        script: |            github.rest.issues.createComment({              issue_number: context.issue.number,              owner: context.repo.owner,              repo: context.repo.repo,              body: "${{ steps.stepone.outputs.long2 }}"            })
You must be logged in to vote

Replies: 1 comment

Comment options

I'd recommend passing inputs through an environment variable into your script rather than inlining the expression.

https://github.com/actions/github-script#use-env-as-input

For example:

    -name:Step3uses:actions/github-script@v6env:LONG_OUTPUT:${{ steps.stepone.outputs.long2 }}with:script:|            github.rest.issues.createComment({              issue_number: context.issue.number,              owner: context.repo.owner,              repo: context.repo.repo,              body: process.env.LONG_OUTPUT            })
You must be logged in to vote
0 replies
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Category
Q&A
Labels
None yet
2 participants
@baxelrod-bdai@joshmgross

[8]ページ先頭

©2009-2025 Movatter.jp