Skip to content

Commit 88bf0de

Browse files
committed
docs: correct examples
1 parent b38e8b0 commit 88bf0de

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

docs/examples.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,9 @@ jobs:
477477
args: --exit-code --recursive --in-place --aggressive --aggressive .
478478
- name: Set autopep8 branch name
479479
id: vars
480-
run: echo ::set-output name=branch-name::"autopep8-patches/${{ github.head_ref }}"
480+
run: |
481+
branch-name="autopep8-patches/${{ github.head_ref }}"
482+
echo "branch-name=$branch-name" >> $GITHUB_OUTPUT
481483
- name: Create Pull Request
482484
if: steps.autopep8.outputs.exit-code == 2
483485
uses: peter-evans/create-pull-request@v4
@@ -527,16 +529,17 @@ jobs:
527529
### Dynamic configuration using variables
528530
529531
The following examples show how configuration for the action can be dynamically defined in a previous workflow step.
530-
531-
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.
532+
Note that the step where output variables are defined must have an id.
532533
533534
```yml
534535
- name: Set output variables
535536
id: vars
536537
run: |
537-
echo ::set-output name=pr_title::"[Test] Add report file $(date +%d-%m-%Y)"
538-
echo ::set-output name=pr_body::"This PR was auto-generated on $(date +%d-%m-%Y) \
538+
pr_title="[Test] Add report file $(date +%d-%m-%Y)"
539+
pr_body="This PR was auto-generated on $(date +%d-%m-%Y) \
539540
by [create-pull-request](https://github.com/peter-evans/create-pull-request)."
541+
echo "pr_title=$pr_title" >> $GITHUB_OUTPUT
542+
echo "pr_body=$pr_body" >> $GITHUB_OUTPUT
540543
- name: Create Pull Request
541544
uses: peter-evans/create-pull-request@v4
542545
with:
@@ -547,16 +550,15 @@ The recommended method is to use [`set-output`](https://docs.github.com/en/actio
547550
### Setting the pull request body from a file
548551
549552
This example shows how file content can be read into a variable and passed to the action.
550-
The content must be [escaped to preserve newlines](https://github.community/t/set-output-truncates-multiline-strings/16852/3).
551553
552554
```yml
553555
- id: get-pr-body
554556
run: |
555557
body=$(cat pr-body.txt)
556-
body="${body//'%'/'%25'}"
557-
body="${body//$'\n'/'%0A'}"
558-
body="${body//$'\r'/'%0D'}"
559-
echo ::set-output name=body::$body
558+
delimiter="$(openssl rand -hex 8)"
559+
echo "body<<$delimiter" >> $GITHUB_OUTPUT
560+
echo "$body" >> $GITHUB_OUTPUT
561+
echo "$delimiter" >> $GITHUB_OUTPUT
560562
561563
- name: Create Pull Request
562564
uses: peter-evans/create-pull-request@v4

0 commit comments

Comments
 (0)