Remove references to stdout commands (#31674)
Co-authored-by: Lucas Costi <lucascosti@users.noreply.github.com>
This commit is contained in:
@@ -81,8 +81,12 @@ Before you begin, you'll create a repository on {% ifversion ghae %}{% data vari
|
|||||||
steps:
|
steps:
|
||||||
- run: echo Hello ${{ inputs.who-to-greet }}.
|
- run: echo Hello ${{ inputs.who-to-greet }}.
|
||||||
shell: bash
|
shell: bash
|
||||||
- id: random-number-generator
|
- id: random-number-generator{% endraw %}
|
||||||
|
{%- ifversion actions-save-state-set-output-envs %}
|
||||||
|
run: echo "random-number=$(echo $RANDOM)" >> $GITHUB_OUTPUT
|
||||||
|
{%- else %}
|
||||||
run: echo "::set-output name=random-number::$(echo $RANDOM)"
|
run: echo "::set-output name=random-number::$(echo $RANDOM)"
|
||||||
|
{%- endif %}{% raw %}
|
||||||
shell: bash
|
shell: bash
|
||||||
- run: echo "${{ github.action_path }}" >> $GITHUB_PATH
|
- run: echo "${{ github.action_path }}" >> $GITHUB_PATH
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ This metadata defines one `who-to-greet` input and one `time` output parameter.
|
|||||||
|
|
||||||
You can choose any base Docker image and, therefore, any language for your action. The following shell script example uses the `who-to-greet` input variable to print "Hello [who-to-greet]" in the log file.
|
You can choose any base Docker image and, therefore, any language for your action. The following shell script example uses the `who-to-greet` input variable to print "Hello [who-to-greet]" in the log file.
|
||||||
|
|
||||||
Next, the script gets the current time and sets it as an output variable that actions running later in a job can use. In order for {% data variables.product.prodname_dotcom %} to recognize output variables, you must use a workflow command in a specific syntax: `echo "::set-output name=<output name>::<value>"`. For more information, see "[Workflow commands for {% data variables.product.prodname_actions %}](/actions/reference/workflow-commands-for-github-actions#setting-an-output-parameter)."
|
Next, the script gets the current time and sets it as an output variable that actions running later in a job can use. In order for {% data variables.product.prodname_dotcom %} to recognize output variables, you must {% ifversion actions-save-state-set-output-envs %}write them to the `$GITHUB_OUTPUT` environment file: `echo "<output name>=<value>" >> $GITHUB_OUTPUT`{% else %}use a workflow command in a specific syntax: `echo "::set-output name=<output name>::<value>"`{% endif %}. For more information, see "[Workflow commands for {% data variables.product.prodname_actions %}](/actions/reference/workflow-commands-for-github-actions#setting-an-output-parameter)."
|
||||||
|
|
||||||
1. Create a new `entrypoint.sh` file in the `hello-world-docker-action` directory.
|
1. Create a new `entrypoint.sh` file in the `hello-world-docker-action` directory.
|
||||||
|
|
||||||
@@ -116,7 +116,11 @@ Next, the script gets the current time and sets it as an output variable that ac
|
|||||||
|
|
||||||
echo "Hello $1"
|
echo "Hello $1"
|
||||||
time=$(date)
|
time=$(date)
|
||||||
|
{%- ifversion actions-save-state-set-output-envs %}
|
||||||
|
echo "time=$time" >> $GITHUB_OUTPUT
|
||||||
|
{%- else %}
|
||||||
echo "::set-output name=time::$time"
|
echo "::set-output name=time::$time"
|
||||||
|
{%- endif %}
|
||||||
```
|
```
|
||||||
If `entrypoint.sh` executes without any errors, the action's status is set to `success`. You can also explicitly set exit codes in your action's code to provide an action's status. For more information, see "[Setting exit codes for actions](/actions/creating-actions/setting-exit-codes-for-actions)."
|
If `entrypoint.sh` executes without any errors, the action's status is set to `success`. You can also explicitly set exit codes in your action's code to provide an action's status. For more information, see "[Setting exit codes for actions](/actions/creating-actions/setting-exit-codes-for-actions)."
|
||||||
|
|
||||||
@@ -168,7 +172,7 @@ The time we greeted you.
|
|||||||
|
|
||||||
## Example usage
|
## Example usage
|
||||||
|
|
||||||
uses: actions/hello-world-docker-action@v1
|
uses: actions/hello-world-docker-action@{% ifversion actions-save-state-set-output-envs %}v2{% else %}v1{% endif %}
|
||||||
with:
|
with:
|
||||||
who-to-greet: 'Mona the Octocat'
|
who-to-greet: 'Mona the Octocat'
|
||||||
```
|
```
|
||||||
@@ -196,7 +200,6 @@ Now you're ready to test your action out in a workflow. When an action is in a p
|
|||||||
|
|
||||||
The following workflow code uses the completed _hello world_ action in the public [`actions/hello-world-docker-action`](https://github.com/actions/hello-world-docker-action) repository. Copy the following workflow example code into a `.github/workflows/main.yml` file, but replace the `actions/hello-world-docker-action` with your repository and action name. You can also replace the `who-to-greet` input with your name. {% ifversion fpt or ghec %}Public actions can be used even if they're not published to {% data variables.product.prodname_marketplace %}. For more information, see "[Publishing an action](/actions/creating-actions/publishing-actions-in-github-marketplace#publishing-an-action)." {% endif %}
|
The following workflow code uses the completed _hello world_ action in the public [`actions/hello-world-docker-action`](https://github.com/actions/hello-world-docker-action) repository. Copy the following workflow example code into a `.github/workflows/main.yml` file, but replace the `actions/hello-world-docker-action` with your repository and action name. You can also replace the `who-to-greet` input with your name. {% ifversion fpt or ghec %}Public actions can be used even if they're not published to {% data variables.product.prodname_marketplace %}. For more information, see "[Publishing an action](/actions/creating-actions/publishing-actions-in-github-marketplace#publishing-an-action)." {% endif %}
|
||||||
|
|
||||||
{% raw %}
|
|
||||||
**.github/workflows/main.yml**
|
**.github/workflows/main.yml**
|
||||||
```yaml{:copy}
|
```yaml{:copy}
|
||||||
on: [push]
|
on: [push]
|
||||||
@@ -208,14 +211,13 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Hello world action step
|
- name: Hello world action step
|
||||||
id: hello
|
id: hello
|
||||||
uses: actions/hello-world-docker-action@v1
|
uses: actions/hello-world-docker-action{% ifversion actions-save-state-set-output-envs %}v2{% else %}v1{% endif %}
|
||||||
with:
|
with:
|
||||||
who-to-greet: 'Mona the Octocat'
|
who-to-greet: 'Mona the Octocat'
|
||||||
# Use the output from the `hello` step
|
# Use the output from the `hello` step
|
||||||
- name: Get the output time
|
- name: Get the output time
|
||||||
run: echo "The time was ${{ steps.hello.outputs.time }}"
|
run: echo "The time was {% raw %}${{ steps.hello.outputs.time }}"{% endraw %}
|
||||||
```
|
```
|
||||||
{% endraw %}
|
|
||||||
|
|
||||||
### Example using a private action
|
### Example using a private action
|
||||||
|
|
||||||
|
|||||||
@@ -125,8 +125,12 @@ outputs:
|
|||||||
runs:
|
runs:
|
||||||
using: "composite"
|
using: "composite"
|
||||||
steps:
|
steps:
|
||||||
- id: random-number-generator
|
- id: random-number-generator{% endraw %}
|
||||||
|
{%- ifversion actions-save-state-set-output-envs %}
|
||||||
|
run: echo "random-id=$(echo $RANDOM)" >> $GITHUB_OUTPUT
|
||||||
|
{%- else %}
|
||||||
run: echo "::set-output name=random-id::$(echo $RANDOM)"
|
run: echo "::set-output name=random-id::$(echo $RANDOM)"
|
||||||
|
{%- endif %}{% raw %}
|
||||||
shell: bash
|
shell: bash
|
||||||
```
|
```
|
||||||
{% endraw %}
|
{% endraw %}
|
||||||
|
|||||||
@@ -143,8 +143,12 @@ jobs:
|
|||||||
# push it to ECR so that it can
|
# push it to ECR so that it can
|
||||||
# be deployed to ECS.
|
# be deployed to ECS.
|
||||||
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
|
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
|
||||||
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
|
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG{% endraw %}
|
||||||
|
{%- ifversion actions-save-state-set-output-envs %}
|
||||||
|
echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT
|
||||||
|
{%- else %}
|
||||||
echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG"
|
echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG"
|
||||||
|
{%- endif %}{% raw %}
|
||||||
|
|
||||||
- name: Fill in the new image ID in the Amazon ECS task definition
|
- name: Fill in the new image ID in the Amazon ECS task definition
|
||||||
id: task-def
|
id: task-def
|
||||||
|
|||||||
@@ -102,7 +102,11 @@ jobs:
|
|||||||
id: composer-cache
|
id: composer-cache
|
||||||
if: steps.check_files.outputs.files_exists == 'true'
|
if: steps.check_files.outputs.files_exists == 'true'
|
||||||
run: |
|
run: |
|
||||||
|
{%- ifversion actions-save-state-set-output-envs %}
|
||||||
|
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
|
||||||
|
{%- else %}
|
||||||
echo "::set-output name=dir::$(composer config cache-files-dir)"
|
echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||||
|
{%- endif %}
|
||||||
|
|
||||||
- name: Set up dependency caching for faster installs
|
- name: Set up dependency caching for faster installs
|
||||||
uses: {% data reusables.actions.action-cache %}
|
uses: {% data reusables.actions.action-cache %}
|
||||||
|
|||||||
@@ -115,7 +115,11 @@ You can then use `curl` to retrieve a JWT from the {% data variables.product.pro
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
jwtd $IDTOKEN
|
jwtd $IDTOKEN
|
||||||
|
{%- ifversion actions-save-state-set-output-envs %}
|
||||||
|
echo "idToken=${IDTOKEN}" >> $GITHUB_OUTPUT
|
||||||
|
{%- else %}
|
||||||
echo "::set-output name=idToken::${IDTOKEN}"
|
echo "::set-output name=idToken::${IDTOKEN}"
|
||||||
|
{%- endif %}
|
||||||
id: tokenid
|
id: tokenid
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -109,7 +109,11 @@ jobs:
|
|||||||
- if: {% raw %}${{ failure() }}{% endraw %}
|
- if: {% raw %}${{ failure() }}{% endraw %}
|
||||||
name: Get title for issue
|
name: Get title for issue
|
||||||
id: check
|
id: check
|
||||||
|
{%- ifversion actions-save-state-set-output-envs %}
|
||||||
|
run: echo "title=$(head -1 broken_links.md)" >> $GITHUB_OUTPUT
|
||||||
|
{%- else %}
|
||||||
run: echo "::set-output name=title::$(head -1 broken_links.md)"
|
run: echo "::set-output name=title::$(head -1 broken_links.md)"
|
||||||
|
{%- endif %}
|
||||||
- if: {% raw %}${{ failure() }}{% endraw %}
|
- if: {% raw %}${{ failure() }}{% endraw %}
|
||||||
name: Create issue from file
|
name: Create issue from file
|
||||||
id: broken-link-report
|
id: broken-link-report
|
||||||
@@ -372,7 +376,11 @@ This `run` command executes a script that is stored in the repository at `script
|
|||||||
- if: {% raw %}${{ failure() }}{% endraw %}
|
- if: {% raw %}${{ failure() }}{% endraw %}
|
||||||
name: Get title for issue
|
name: Get title for issue
|
||||||
id: check
|
id: check
|
||||||
|
{%- ifversion actions-save-state-set-output-envs %}
|
||||||
|
run: echo "title=$(head -1 broken_links.md)" >> $GITHUB_OUTPUT
|
||||||
|
{%- else %}
|
||||||
run: echo "::set-output name=title::$(head -1 broken_links.md)"
|
run: echo "::set-output name=title::$(head -1 broken_links.md)"
|
||||||
|
{%- endif %}
|
||||||
```
|
```
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ The following scripting languages are supported:
|
|||||||
Your custom scripts can use the following features:
|
Your custom scripts can use the following features:
|
||||||
|
|
||||||
- **Environment variables**: Scripts have access to the default environment variables. The full webhook event payload can be found in `GITHUB_EVENT_PATH`. For more information, see "[Environment variables](/actions/learn-github-actions/environment-variables#default-environment-variables)."
|
- **Environment variables**: Scripts have access to the default environment variables. The full webhook event payload can be found in `GITHUB_EVENT_PATH`. For more information, see "[Environment variables](/actions/learn-github-actions/environment-variables#default-environment-variables)."
|
||||||
- **Workflow commands**: Scripts can use workflow commands. For more information, see ["Workflow commands for {% data variables.product.prodname_actions %}"](/actions/using-workflows/workflow-commands-for-github-actions), with the exception of `save-state` and `set-output`, which are not supported by these scripts. Scripts can also use environment files. For more information, see [Environment files](/actions/using-workflows/workflow-commands-for-github-actions#environment-files).
|
- **Workflow commands**: Scripts can use workflow commands. For more information, see ["Workflow commands for {% data variables.product.prodname_actions %}"](/actions/using-workflows/workflow-commands-for-github-actions){% ifversion actions-save-state-set-output-envs %}{% else %}, with the exception of `save-state` and `set-output`, which are not supported by these scripts{% endif %}. Scripts can also use environment files. For more information, see [Environment files](/actions/using-workflows/workflow-commands-for-github-actions#environment-files).
|
||||||
|
|
||||||
{% note %}
|
{% note %}
|
||||||
|
|
||||||
|
|||||||
@@ -469,10 +469,18 @@ jobs:
|
|||||||
output1: ${{ steps.step1.outputs.firstword }}
|
output1: ${{ steps.step1.outputs.firstword }}
|
||||||
output2: ${{ steps.step2.outputs.secondword }}
|
output2: ${{ steps.step2.outputs.secondword }}
|
||||||
steps:
|
steps:
|
||||||
- id: step1
|
- id: step1{% endraw %}
|
||||||
|
{%- ifversion actions-save-state-set-output-envs %}
|
||||||
|
run: echo "firstword=hello" >> $GITHUB_OUTPUT
|
||||||
|
{%- else %}
|
||||||
run: echo "::set-output name=firstword::hello"
|
run: echo "::set-output name=firstword::hello"
|
||||||
- id: step2
|
{%- endif %}{% raw %}
|
||||||
|
- id: step2{% endraw %}
|
||||||
|
{%- ifversion actions-save-state-set-output-envs %}
|
||||||
|
run: echo "secondword=world" >> $GITHUB_OUTPUT
|
||||||
|
{%- else %}
|
||||||
run: echo "::set-output name=secondword::world"
|
run: echo "::set-output name=secondword::world"
|
||||||
|
{%- endif %}{% raw %}
|
||||||
```
|
```
|
||||||
{% endraw %}
|
{% endraw %}
|
||||||
|
|
||||||
@@ -526,7 +534,11 @@ jobs:
|
|||||||
uses: {% data reusables.actions.action-checkout %}
|
uses: {% data reusables.actions.action-checkout %}
|
||||||
- name: Generate 0 or 1
|
- name: Generate 0 or 1
|
||||||
id: generate_number
|
id: generate_number
|
||||||
|
{%- ifversion actions-save-state-set-output-envs %}
|
||||||
|
run: echo "random_number=$(($RANDOM % 2))" >> $GITHUB_OUTPUT
|
||||||
|
{%- else %}
|
||||||
run: echo "::set-output name=random_number::$(($RANDOM % 2))"
|
run: echo "::set-output name=random_number::$(($RANDOM % 2))"
|
||||||
|
{%- endif %}
|
||||||
- name: Pass or fail
|
- name: Pass or fail
|
||||||
run: |
|
run: |
|
||||||
if [[ {% raw %}${{ steps.generate_number.outputs.random_number }}{% endraw %} == 0 ]]; then exit 0; else exit 1; fi
|
if [[ {% raw %}${{ steps.generate_number.outputs.random_number }}{% endraw %} == 0 ]]; then exit 0; else exit 1; fi
|
||||||
@@ -772,7 +784,11 @@ jobs:
|
|||||||
id: build_step
|
id: build_step
|
||||||
run: |
|
run: |
|
||||||
./build
|
./build
|
||||||
|
{%- ifversion actions-save-state-set-output-envs %}
|
||||||
|
echo "build_id=$BUILD_ID" >> $GITHUB_OUTPUT
|
||||||
|
{%- else %}
|
||||||
echo "::set-output name=build_id::$BUILD_ID"
|
echo "::set-output name=build_id::$BUILD_ID"
|
||||||
|
{%- endif %}
|
||||||
deploy:
|
deploy:
|
||||||
needs: build
|
needs: build
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|||||||
@@ -223,8 +223,12 @@ jobs:
|
|||||||
outputs:
|
outputs:
|
||||||
matrix: ${{ steps.set-matrix.outputs.matrix }}
|
matrix: ${{ steps.set-matrix.outputs.matrix }}
|
||||||
steps:
|
steps:
|
||||||
- id: set-matrix
|
- id: set-matrix{% endraw %}
|
||||||
|
{%- ifversion actions-save-state-set-output-envs %}
|
||||||
|
run: echo "matrix={\"include\":[{\"project\":\"foo\",\"config\":\"Debug\"},{\"project\":\"bar\",\"config\":\"Release\"}]}" >> $GITHUB_OUTPUT
|
||||||
|
{%- else %}
|
||||||
run: echo "::set-output name=matrix::{\"include\":[{\"project\":\"foo\",\"config\":\"Debug\"},{\"project\":\"bar\",\"config\":\"Release\"}]}"
|
run: echo "::set-output name=matrix::{\"include\":[{\"project\":\"foo\",\"config\":\"Debug\"},{\"project\":\"bar\",\"config\":\"Release\"}]}"
|
||||||
|
{%- endif %}{% raw %}
|
||||||
job2:
|
job2:
|
||||||
needs: job1
|
needs: job1
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|||||||
@@ -367,10 +367,18 @@ jobs:
|
|||||||
output1: ${{ steps.step1.outputs.firstword }}
|
output1: ${{ steps.step1.outputs.firstword }}
|
||||||
output2: ${{ steps.step2.outputs.secondword }}
|
output2: ${{ steps.step2.outputs.secondword }}
|
||||||
steps:
|
steps:
|
||||||
- id: step1
|
- id: step1{% endraw %}
|
||||||
|
{%- ifversion actions-save-state-set-output-envs %}
|
||||||
|
run: echo "firstword=hello" >> $GITHUB_OUTPUT
|
||||||
|
{%- else %}
|
||||||
run: echo "::set-output name=firstword::hello"
|
run: echo "::set-output name=firstword::hello"
|
||||||
- id: step2
|
{%- endif %}{% raw %}
|
||||||
|
- id: step2{% endraw %}
|
||||||
|
{%- ifversion actions-save-state-set-output-envs %}
|
||||||
|
run: echo "secondword=world" >> $GITHUB_OUTPUT
|
||||||
|
{%- else %}
|
||||||
run: echo "::set-output name=secondword::world"
|
run: echo "::set-output name=secondword::world"
|
||||||
|
{%- endif %}{% raw %}
|
||||||
```
|
```
|
||||||
{% endraw %}
|
{% endraw %}
|
||||||
|
|
||||||
|
|||||||
@@ -481,6 +481,7 @@ jobs:
|
|||||||
|
|
||||||
{% endpowershell %}
|
{% endpowershell %}
|
||||||
|
|
||||||
|
{% ifversion actions-save-state-set-output-envs %}{% else %}
|
||||||
## Echoing command outputs
|
## Echoing command outputs
|
||||||
|
|
||||||
Enables or disables echoing of workflow commands. For example, if you use the `set-output` command in a workflow, it sets an output parameter but the workflow run's log does not show the command itself. If you enable command echoing, then the log shows the command, such as `::set-output name={name}::{value}`.
|
Enables or disables echoing of workflow commands. For example, if you use the `set-output` command in a workflow, it sets an output parameter but the workflow run's log does not show the command itself. If you enable command echoing, then the log shows the command, such as `::set-output name={name}::{value}`.
|
||||||
@@ -543,6 +544,8 @@ The example above prints the following lines to the log:
|
|||||||
|
|
||||||
Only the second `set-output` and `echo` workflow commands are included in the log because command echoing was only enabled when they were run. Even though it is not always echoed, the output parameter is set in all cases.
|
Only the second `set-output` and `echo` workflow commands are included in the log because command echoing was only enabled when they were run. Even though it is not always echoed, the output parameter is set in all cases.
|
||||||
|
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
## Sending values to the pre and post actions
|
## Sending values to the pre and post actions
|
||||||
|
|
||||||
{% ifversion actions-save-state-set-output-envs %}You can create environment variables for sharing with your workflow's `pre:` or `post:` actions by writing to the file located at `GITHUB_STATE`{% else %}You can use the `save-state` command to create environment variables for sharing with your workflow's `pre:` or `post:` actions{% endif %}. For example, you can create a file with the `pre:` action, pass the file location to the `main:` action, and then use the `post:` action to delete the file. Alternatively, you could create a file with the `main:` action, pass the file location to the `post:` action, and also use the `post:` action to delete the file.
|
{% ifversion actions-save-state-set-output-envs %}You can create environment variables for sharing with your workflow's `pre:` or `post:` actions by writing to the file located at `GITHUB_STATE`{% else %}You can use the `save-state` command to create environment variables for sharing with your workflow's `pre:` or `post:` actions{% endif %}. For example, you can create a file with the `pre:` action, pass the file location to the `main:` action, and then use the `post:` action to delete the file. Alternatively, you could create a file with the `main:` action, pass the file location to the `post:` action, and also use the `post:` action to delete the file.
|
||||||
|
|||||||
@@ -18,10 +18,18 @@ jobs:
|
|||||||
output1: ${{ steps.step1.outputs.test }}
|
output1: ${{ steps.step1.outputs.test }}
|
||||||
output2: ${{ steps.step2.outputs.test }}
|
output2: ${{ steps.step2.outputs.test }}
|
||||||
steps:
|
steps:
|
||||||
- id: step1
|
- id: step1{% endraw %}
|
||||||
|
{%- ifversion actions-save-state-set-output-envs %}
|
||||||
|
run: echo "test=hello" >> $GITHUB_OUTPUT
|
||||||
|
{%- else %}
|
||||||
run: echo "::set-output name=test::hello"
|
run: echo "::set-output name=test::hello"
|
||||||
- id: step2
|
{%- endif %}{% raw %}
|
||||||
|
- id: step2{% endraw %}
|
||||||
|
{%- ifversion actions-save-state-set-output-envs %}
|
||||||
|
run: echo "test=world" >> $GITHUB_OUTPUT
|
||||||
|
{%- else %}
|
||||||
run: echo "::set-output name=test::world"
|
run: echo "::set-output name=test::world"
|
||||||
|
{%- endif %}{% raw %}
|
||||||
job2:
|
job2:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: job1
|
needs: job1
|
||||||
|
|||||||
Reference in New Issue
Block a user