From 71a37c5c334c3a5f6e352223089ac3bb0a651b13 Mon Sep 17 00:00:00 2001 From: Peter Evans Date: Fri, 31 Jul 2020 10:24:31 +0900 Subject: [PATCH] Update documentation --- docs/examples.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/docs/examples.md b/docs/examples.md index a24c09e..453408e 100644 --- a/docs/examples.md +++ b/docs/examples.md @@ -440,6 +440,26 @@ Alternatively, [`set-env`](https://help.github.com/en/github/automating-your-wor body: ${{ env.PULL_REQUEST_BODY }} ``` +### Setting the pull request body from a file + +This example shows how file content can be read into a variable and passed to the action. +The content must be [escaped to preserve newlines](https://github.community/t/set-output-truncates-multiline-strings/16852/3). + +```yml + - id: get-pr-body + run: | + body=$(cat pr-body.txt) + body="${body//'%'/'%25'}" + body="${body//$'\n'/'%0A'}" + body="${body//$'\r'/'%0D'}" + echo ::set-output name=body::$body + + - name: Create Pull Request + uses: peter-evans/create-pull-request@v3 + with: + body: ${{ steps.get-pr-body.outputs.body }} +``` + ### Debugging GitHub Actions #### Runner Diagnostic Logging