From 88bf0de51c7487d91e1abbb4899332e602c58bbf Mon Sep 17 00:00:00 2001 From: Peter Evans <18365890+peter-evans@users.noreply.github.com> Date: Fri, 21 Oct 2022 14:01:58 +0900 Subject: [PATCH] docs: correct examples --- docs/examples.md | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/docs/examples.md b/docs/examples.md index f83c3a003f..86295e967a 100644 --- a/docs/examples.md +++ b/docs/examples.md @@ -477,7 +477,9 @@ jobs: args: --exit-code --recursive --in-place --aggressive --aggressive . - name: Set autopep8 branch name id: vars - run: echo ::set-output name=branch-name::"autopep8-patches/${{ github.head_ref }}" + run: | + branch-name="autopep8-patches/${{ github.head_ref }}" + echo "branch-name=$branch-name" >> $GITHUB_OUTPUT - name: Create Pull Request if: steps.autopep8.outputs.exit-code == 2 uses: peter-evans/create-pull-request@v4 @@ -527,16 +529,17 @@ jobs: ### Dynamic configuration using variables The following examples show how configuration for the action can be dynamically defined in a previous workflow step. - -The recommended method is to use [`set-output`](https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-output-parameter). Note that the step where output variables are defined must have an id. +Note that the step where output variables are defined must have an id. ```yml - name: Set output variables id: vars run: | - echo ::set-output name=pr_title::"[Test] Add report file $(date +%d-%m-%Y)" - echo ::set-output name=pr_body::"This PR was auto-generated on $(date +%d-%m-%Y) \ + pr_title="[Test] Add report file $(date +%d-%m-%Y)" + pr_body="This PR was auto-generated on $(date +%d-%m-%Y) \ by [create-pull-request](https://github.com/peter-evans/create-pull-request)." + echo "pr_title=$pr_title" >> $GITHUB_OUTPUT + echo "pr_body=$pr_body" >> $GITHUB_OUTPUT - name: Create Pull Request uses: peter-evans/create-pull-request@v4 with: @@ -547,16 +550,15 @@ The recommended method is to use [`set-output`](https://docs.github.com/en/actio ### 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 + delimiter="$(openssl rand -hex 8)" + echo "body<<$delimiter" >> $GITHUB_OUTPUT + echo "$body" >> $GITHUB_OUTPUT + echo "$delimiter" >> $GITHUB_OUTPUT - name: Create Pull Request uses: peter-evans/create-pull-request@v4