Remove references to stdout commands (#31674)

Co-authored-by: Lucas Costi <lucascosti@users.noreply.github.com>
This commit is contained in:
Francesco Renzi 2022-10-17 02:09:57 +01:00 коммит произвёл GitHub
Родитель b88af49652
Коммит ad70a7012f
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
13 изменённых файлов: 103 добавлений и 34 удалений

Просмотреть файл

@ -81,11 +81,15 @@ Before you begin, you'll create a repository on {% ifversion ghae %}{% data vari
steps:
- run: echo Hello ${{ inputs.who-to-greet }}.
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)"
{%- endif %}{% raw %}
shell: bash
- run: echo "${{ github.action_path }}" >> $GITHUB_PATH
shell: bash
shell: bash
- run: goodbye.sh
shell: bash
```

Просмотреть файл

@ -38,7 +38,7 @@ You may find it helpful to have a basic understanding of {% data variables.produ
- "[Using environment variables](/actions/automating-your-workflow-with-github-actions/using-environment-variables)"
{% ifversion ghae %}
- "[Docker container filesystem](/actions/using-github-hosted-runners/about-ae-hosted-runners#docker-container-filesystem)."
{% else %}
{% else %}
- "[About {% data variables.product.prodname_dotcom %}-hosted runners](/actions/using-github-hosted-runners/about-github-hosted-runners#docker-container-filesystem)"
{% endif %}
@ -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.
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.
@ -116,7 +116,11 @@ Next, the script gets the current time and sets it as an output variable that ac
echo "Hello $1"
time=$(date)
{%- ifversion actions-save-state-set-output-envs %}
echo "time=$time" >> $GITHUB_OUTPUT
{%- else %}
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)."
@ -126,7 +130,7 @@ Next, the script gets the current time and sets it as an output variable that ac
```shell{:copy}
$ git update-index --chmod=+x entrypoint.sh
```
1. Optionally, to check the permission mode of the file in the git index, run the following command.
```shell{:copy}
@ -168,7 +172,7 @@ The time we greeted you.
## 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:
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 %}
{% raw %}
**.github/workflows/main.yml**
```yaml{:copy}
on: [push]
@ -208,14 +211,13 @@ jobs:
steps:
- name: Hello world action step
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:
who-to-greet: 'Mona the Octocat'
# Use the output from the `hello` step
- 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

Просмотреть файл

@ -58,7 +58,7 @@ inputs:
When you specify an input in a workflow file or use a default input value, {% data variables.product.prodname_dotcom %} creates an environment variable for the input with the name `INPUT_<VARIABLE_NAME>`. The environment variable created converts input names to uppercase letters and replaces spaces with `_` characters.
If the action is written using a [composite](/actions/creating-actions/creating-a-composite-action), then it will not automatically get `INPUT_<VARIABLE_NAME>`. If the conversion doesn't occur, you can change these inputs manually.
If the action is written using a [composite](/actions/creating-actions/creating-a-composite-action), then it will not automatically get `INPUT_<VARIABLE_NAME>`. If the conversion doesn't occur, you can change these inputs manually.
To access the environment variable in a Docker container action, you must pass the input using the `args` keyword in the action metadata file. For more information about the action metadata file for Docker container actions, see "[Creating a Docker container action](/articles/creating-a-docker-container-action#creating-an-action-metadata-file)."
@ -125,8 +125,12 @@ outputs:
runs:
using: "composite"
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)"
{%- endif %}{% raw %}
shell: bash
```
{% endraw %}
@ -155,7 +159,7 @@ runs:
### `runs.using`
**Required** The runtime used to execute the code specified in [`main`](#runsmain).
**Required** The runtime used to execute the code specified in [`main`](#runsmain).
- Use `node12` for Node.js v12.{% ifversion fpt or ghes > 3.3 or ghae > 3.3 or ghec %}
- Use `node16` for Node.js v16.{% endif %}
@ -365,7 +369,7 @@ runs:
with:
first_name: Mona
middle_name: The
last_name: Octocat
last_name: Octocat
```
{% endif %}
@ -481,7 +485,7 @@ runs:
```yaml
branding:
icon: 'award'
icon: 'award'
color: 'green'
```
@ -522,9 +526,9 @@ The name of the v4.28.0 [Feather](https://feathericons.com/) icon to use. Brand
Here is an exhaustive list of all currently supported icons:
<!--
<!--
This table should match the icon list in `app/models/repository_actions/icons.rb` in the internal github repo.
To support a new icon, update `app/models/repository_actions/icons.rb` and add the svg to `/static/images/icons/feather` in the internal github repo.
To support a new icon, update `app/models/repository_actions/icons.rb` and add the svg to `/static/images/icons/feather` in the internal github repo.
-->
<table>

Просмотреть файл

@ -143,8 +143,12 @@ jobs:
# push it to ECR so that it can
# be deployed to ECS.
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"
{%- endif %}{% raw %}
- name: Fill in the new image ID in the Amazon ECS task definition
id: task-def

Просмотреть файл

@ -102,7 +102,11 @@ jobs:
id: composer-cache
if: steps.check_files.outputs.files_exists == 'true'
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)"
{%- endif %}
- name: Set up dependency caching for faster installs
uses: {% data reusables.actions.action-cache %}

Просмотреть файл

@ -17,7 +17,7 @@ topics:
## Overview
OpenID Connect (OIDC) allows your {% data variables.product.prodname_actions %} workflows to access resources in your cloud provider, without having to store any credentials as long-lived {% data variables.product.prodname_dotcom %} secrets.
OpenID Connect (OIDC) allows your {% data variables.product.prodname_actions %} workflows to access resources in your cloud provider, without having to store any credentials as long-lived {% data variables.product.prodname_dotcom %} secrets.
To use OIDC, you will first need to configure your cloud provider to trust {% data variables.product.prodname_dotcom %}'s OIDC as a federated identity, and must then update your workflows to authenticate using tokens.
@ -45,7 +45,7 @@ If your cloud provider has created an official action for using OIDC with {% dat
## Using custom actions
If your cloud provider doesn't have an official action, or if you prefer to create custom scripts, you can manually request the JSON Web Token (JWT) from {% data variables.product.prodname_dotcom %}'s OIDC provider.
If your cloud provider doesn't have an official action, or if you prefer to create custom scripts, you can manually request the JSON Web Token (JWT) from {% data variables.product.prodname_dotcom %}'s OIDC provider.
If you're not using an official action, then {% data variables.product.prodname_dotcom %} recommends that you use the Actions core toolkit. Alternatively, you can use the following environment variables to retrieve the token: `ACTIONS_RUNTIME_TOKEN`, `ACTIONS_ID_TOKEN_REQUEST_URL`.
@ -73,8 +73,8 @@ jobs:
with:
script: |
const coredemo = require('@actions/core')
let id_token = await coredemo.getIDToken()
coredemo.setOutput('id_token', id_token)
let id_token = await coredemo.getIDToken()
coredemo.setOutput('id_token', id_token)
```
### Requesting the JWT using environment variables
@ -115,7 +115,11 @@ You can then use `curl` to retrieve a JWT from the {% data variables.product.pro
fi
}
jwtd $IDTOKEN
{%- ifversion actions-save-state-set-output-envs %}
echo "idToken=${IDTOKEN}" >> $GITHUB_OUTPUT
{%- else %}
echo "::set-output name=idToken::${IDTOKEN}"
{%- endif %}
id: tokenid
```
@ -125,8 +129,8 @@ You will need to present the OIDC JSON web token to your cloud provider in order
For each deployment, your workflows must use cloud login actions (or custom scripts) that fetch the OIDC token and present it to your cloud provider. The cloud provider then validates the claims in the token; if successful, it provides a cloud access token that is available only to that job run. The provided access token can then be used by subsequent actions in the job to connect to the cloud and deploy to its resources.
The steps for exchanging the OIDC token for an access token will vary for each cloud provider.
The steps for exchanging the OIDC token for an access token will vary for each cloud provider.
### Accessing resources in your cloud provider
Once you've obtained the access token, you can use specific cloud actions or scripts to authenticate to the cloud provider and deploy to its resources. These steps could differ for each cloud provider.

Просмотреть файл

@ -109,7 +109,11 @@ jobs:
- if: {% raw %}${{ failure() }}{% endraw %}
name: Get title for issue
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)"
{%- endif %}
- if: {% raw %}${{ failure() }}{% endraw %}
name: Create issue from file
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 %}
name: Get title for issue
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)"
{%- endif %}
```
</td>
<td>

Просмотреть файл

@ -30,7 +30,7 @@ The following scripting languages are supported:
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)."
- **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 %}

Просмотреть файл

@ -469,10 +469,18 @@ jobs:
output1: ${{ steps.step1.outputs.firstword }}
output2: ${{ steps.step2.outputs.secondword }}
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"
- 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"
{%- endif %}{% raw %}
```
{% endraw %}
@ -526,7 +534,11 @@ jobs:
uses: {% data reusables.actions.action-checkout %}
- name: Generate 0 or 1
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))"
{%- endif %}
- name: Pass or fail
run: |
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
run: |
./build
{%- ifversion actions-save-state-set-output-envs %}
echo "build_id=$BUILD_ID" >> $GITHUB_OUTPUT
{%- else %}
echo "::set-output name=build_id::$BUILD_ID"
{%- endif %}
deploy:
needs: build
runs-on: ubuntu-latest

Просмотреть файл

@ -223,8 +223,12 @@ jobs:
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
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\"}]}"
{%- endif %}{% raw %}
job2:
needs: job1
runs-on: ubuntu-latest

Просмотреть файл

@ -115,7 +115,7 @@ You can define inputs and secrets, which can be passed from the caller workflow
{% endraw %}
For details of the syntax for defining inputs and secrets, see [`on.workflow_call.inputs`](/actions/reference/workflow-syntax-for-github-actions#onworkflow_callinputs) and [`on.workflow_call.secrets`](/actions/reference/workflow-syntax-for-github-actions#onworkflow_callsecrets).
{% ifversion actions-inherit-secrets-reusable-workflows %}
1. In the reusable workflow, reference the input or secret that you defined in the `on` key in the previous step.
1. In the reusable workflow, reference the input or secret that you defined in the `on` key in the previous step.
{% note %}
@ -338,7 +338,7 @@ For information on how to use the API to determine which workflow files were inv
A reusable workflow may generate data that you want to use in the caller workflow. To use these outputs, you must specify them as the outputs of the reusable workflow.{% ifversion actions-reusable-workflow-matrix %}
If a reusable workflow that sets an output is executed with a matrix strategy, the output will be the output set by the last successful completing reusable workflow of the matrix which actually sets a value.
If a reusable workflow that sets an output is executed with a matrix strategy, the output will be the output set by the last successful completing reusable workflow of the matrix which actually sets a value.
That means if the last successful completing reusable workflow sets an empty string for its output, and the second last successful completing reusable workflow sets an actual value for its output, the output will contain the value of the second last completing reusable workflow.{% endif %}
The following reusable workflow has a single job containing two steps. In each of these steps we set a single word as the output: "hello" and "world." In the `outputs` section of the job, we map these step outputs to job outputs called: `output1` and `output2`. In the `on.workflow_call.outputs` section we then define two outputs for the workflow itself, one called `firstword` which we map to `output1`, and one called `secondword` which we map to `output2`.
@ -367,10 +367,18 @@ jobs:
output1: ${{ steps.step1.outputs.firstword }}
output2: ${{ steps.step2.outputs.secondword }}
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"
- 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"
{%- endif %}{% raw %}
```
{% endraw %}

Просмотреть файл

@ -481,6 +481,7 @@ jobs:
{% endpowershell %}
{% ifversion actions-save-state-set-output-envs %}{% else %}
## 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}`.
@ -542,6 +543,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.
{% endif %}
## Sending values to the pre and post actions

Просмотреть файл

@ -18,10 +18,18 @@ jobs:
output1: ${{ steps.step1.outputs.test }}
output2: ${{ steps.step2.outputs.test }}
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"
- 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"
{%- endif %}{% raw %}
job2:
runs-on: ubuntu-latest
needs: job1