From 181dcc219c4b6631bb79d68844fc12df4b7cdf2e Mon Sep 17 00:00:00 2001 From: Jonathan Clem Date: Mon, 18 May 2020 12:51:39 -0400 Subject: [PATCH 1/4] Add step results section to readme --- README.md | 52 +++++++++++++++++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 7fe9f266b..3661cc7df 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,36 @@ future versions. 🙂 See [development.md](/docs/development.md). +## Reading step results + +The return value of the script will be in the step's outputs under the +"result" key. + +```yaml +- uses: actions/github-script@0.9.0 + id: set-result + with: + script: return "Hello!" + result-encoding: string +- name: Get result + run: echo "${{steps.my-script.outputs.result}}" +``` + +## Result encoding + +By default, the JSON-encoded return value of the function is set as the "result" in the +output of a github-script step. For some workflows, string encoding is preferred. This option can be set using the +`result-encoding` input: + +```yaml +- uses: actions/github-script@0.9.0 + id: my-script + with: + github-token: ${{secrets.GITHUB_TOKEN}} + result-encoding: string + script: return "I will be string (not JSON) encoded!" +``` + ## Examples Note that `github-token` is optional in this action, and the input is there @@ -141,6 +171,9 @@ jobs: console.log(result) ``` +See ["Result encoding"](#result-encoding) for details on how the encoding of +these outputs can be changed. + This will print the full diff object in the screen; `result.data` will contain the actual diff text. @@ -178,22 +211,3 @@ the inline script. Note that because you can't `require` things like the GitHub context or Actions Toolkit libraries, you'll want to pass them as arguments to your external function. - -### Result encoding - -By default, the JSON-encoded return value of the function is set as the "result" in the -output of a github-script step. For some workflows, string encoding is preferred. This option can be set using the -`result-encoding` input: - -```yaml -- uses: actions/github-script@0.9.0 - id: my-script - with: - github-token: ${{secrets.GITHUB_TOKEN}} - result-encoding: string - script: | - return "I will be string (not JSON) encoded!" - -- name: Prints result - run: cat '${{ steps.my-script.outputs.result }}' -``` From adb3d5168d2c94341ab88613463d622adf64d993 Mon Sep 17 00:00:00 2001 From: Jonathan Clem Date: Mon, 18 May 2020 12:52:37 -0400 Subject: [PATCH 2/4] Fix section not moved --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 3661cc7df..602ba0b68 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,12 @@ The return value of the script will be in the step's outputs under the run: echo "${{steps.my-script.outputs.result}}" ``` +See ["Result encoding"](#result-encoding) for details on how the encoding of +these outputs can be changed. + +This will print the full diff object in the screen; `result.data` will +contain the actual diff text. + ## Result encoding By default, the JSON-encoded return value of the function is set as the "result" in the @@ -171,12 +177,6 @@ jobs: console.log(result) ``` -See ["Result encoding"](#result-encoding) for details on how the encoding of -these outputs can be changed. - -This will print the full diff object in the screen; `result.data` will -contain the actual diff text. - ### Run a separate file If you don't want to inline your entire script that you want to run, you can From 5d33ffc89dc9605d1478fc9b01857b20ce29244f Mon Sep 17 00:00:00 2001 From: Jonathan Clem Date: Mon, 18 May 2020 12:53:18 -0400 Subject: [PATCH 3/4] Fix step ID in output example --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 602ba0b68..765d55e5a 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ The return value of the script will be in the step's outputs under the script: return "Hello!" result-encoding: string - name: Get result - run: echo "${{steps.my-script.outputs.result}}" + run: echo "${{steps.set-result.outputs.result}}" ``` See ["Result encoding"](#result-encoding) for details on how the encoding of From dd16c14e710b95a4ba006a6b07a3432df733c5b3 Mon Sep 17 00:00:00 2001 From: Jonathan Clem Date: Mon, 18 May 2020 12:54:07 -0400 Subject: [PATCH 4/4] Move another section in the wrong place --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 765d55e5a..32d10ccd3 100644 --- a/README.md +++ b/README.md @@ -44,9 +44,6 @@ The return value of the script will be in the step's outputs under the See ["Result encoding"](#result-encoding) for details on how the encoding of these outputs can be changed. -This will print the full diff object in the screen; `result.data` will -contain the actual diff text. - ## Result encoding By default, the JSON-encoded return value of the function is set as the "result" in the @@ -177,6 +174,9 @@ jobs: console.log(result) ``` +This will print the full diff object in the screen; `result.data` will +contain the actual diff text. + ### Run a separate file If you don't want to inline your entire script that you want to run, you can