Skip to content

Handling multiline set-env when command errors out #26405

Discussion options

You must be logged in to vote

Yea the tricky bit here is that I actually want the step to result in a failed status which I surface in a PR message. I ended up getting passed this by writing the output to a temporary file and reading it the next step.

     - name: Multiline Test
        id: multiline
        run: |
          a-command-that-can-fail > "$RUNNER_TEMP/output.txt"
        continue-on-error: true

Then I retrieved the contents in the next step with actions/github-script

            const tempDirectory = process.env['RUNNER_TEMP']
        const fs = require('fs').promises
        const planContents = await fs.readFile(`${tempDirectory}/output.txt`, {encoding: 'utf8'})

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
2 participants