diff --git a/content/actions/creating-actions/creating-a-composite-action.md b/content/actions/creating-actions/creating-a-composite-action.md index f84e6475ca..5874bfae6e 100644 --- a/content/actions/creating-actions/creating-a-composite-action.md +++ b/content/actions/creating-actions/creating-a-composite-action.md @@ -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 ``` diff --git a/content/actions/creating-actions/creating-a-docker-container-action.md b/content/actions/creating-actions/creating-a-docker-container-action.md index 9e940b54dc..6d91c1035f 100644 --- a/content/actions/creating-actions/creating-a-docker-container-action.md +++ b/content/actions/creating-actions/creating-a-docker-container-action.md @@ -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=::"`. 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 "=" >> $GITHUB_OUTPUT`{% else %}use a workflow command in a specific syntax: `echo "::set-output name=::"`{% 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 diff --git a/content/actions/creating-actions/metadata-syntax-for-github-actions.md b/content/actions/creating-actions/metadata-syntax-for-github-actions.md index 58a58b0664..5409856a9d 100644 --- a/content/actions/creating-actions/metadata-syntax-for-github-actions.md +++ b/content/actions/creating-actions/metadata-syntax-for-github-actions.md @@ -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_`. 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_`. 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_`. 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: - diff --git a/content/actions/deployment/deploying-to-your-cloud-provider/deploying-to-amazon-elastic-container-service.md b/content/actions/deployment/deploying-to-your-cloud-provider/deploying-to-amazon-elastic-container-service.md index 42292165d2..abc8392e96 100644 --- a/content/actions/deployment/deploying-to-your-cloud-provider/deploying-to-amazon-elastic-container-service.md +++ b/content/actions/deployment/deploying-to-your-cloud-provider/deploying-to-amazon-elastic-container-service.md @@ -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 diff --git a/content/actions/deployment/deploying-to-your-cloud-provider/deploying-to-azure/deploying-php-to-azure-app-service.md b/content/actions/deployment/deploying-to-your-cloud-provider/deploying-to-azure/deploying-php-to-azure-app-service.md index 882844a780..ff5236a5ca 100644 --- a/content/actions/deployment/deploying-to-your-cloud-provider/deploying-to-azure/deploying-php-to-azure-app-service.md +++ b/content/actions/deployment/deploying-to-your-cloud-provider/deploying-to-azure/deploying-php-to-azure-app-service.md @@ -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 %} diff --git a/content/actions/deployment/security-hardening-your-deployments/configuring-openid-connect-in-cloud-providers.md b/content/actions/deployment/security-hardening-your-deployments/configuring-openid-connect-in-cloud-providers.md index 81edb8dfcb..42683676cd 100644 --- a/content/actions/deployment/security-hardening-your-deployments/configuring-openid-connect-in-cloud-providers.md +++ b/content/actions/deployment/security-hardening-your-deployments/configuring-openid-connect-in-cloud-providers.md @@ -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. diff --git a/content/actions/examples/using-the-github-cli-on-a-runner.md b/content/actions/examples/using-the-github-cli-on-a-runner.md index cab7c4b9e3..351014a933 100644 --- a/content/actions/examples/using-the-github-cli-on-a-runner.md +++ b/content/actions/examples/using-the-github-cli-on-a-runner.md @@ -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 %} ```
diff --git a/content/actions/hosting-your-own-runners/running-scripts-before-or-after-a-job.md b/content/actions/hosting-your-own-runners/running-scripts-before-or-after-a-job.md index 695e4b385b..ec7997a3c2 100644 --- a/content/actions/hosting-your-own-runners/running-scripts-before-or-after-a-job.md +++ b/content/actions/hosting-your-own-runners/running-scripts-before-or-after-a-job.md @@ -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 %} diff --git a/content/actions/learn-github-actions/contexts.md b/content/actions/learn-github-actions/contexts.md index 2f4ce65742..2629ad6dba 100644 --- a/content/actions/learn-github-actions/contexts.md +++ b/content/actions/learn-github-actions/contexts.md @@ -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 diff --git a/content/actions/learn-github-actions/expressions.md b/content/actions/learn-github-actions/expressions.md index d5d302ff5c..0bf64804d3 100644 --- a/content/actions/learn-github-actions/expressions.md +++ b/content/actions/learn-github-actions/expressions.md @@ -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 diff --git a/content/actions/using-workflows/reusing-workflows.md b/content/actions/using-workflows/reusing-workflows.md index 016cb10829..79095d002c 100644 --- a/content/actions/using-workflows/reusing-workflows.md +++ b/content/actions/using-workflows/reusing-workflows.md @@ -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 %} diff --git a/content/actions/using-workflows/workflow-commands-for-github-actions.md b/content/actions/using-workflows/workflow-commands-for-github-actions.md index 60e836a70a..4aaef727ee 100644 --- a/content/actions/using-workflows/workflow-commands-for-github-actions.md +++ b/content/actions/using-workflows/workflow-commands-for-github-actions.md @@ -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 diff --git a/data/reusables/actions/jobs/section-defining-outputs-for-jobs.md b/data/reusables/actions/jobs/section-defining-outputs-for-jobs.md index 8fe124a3bd..15b3fea980 100644 --- a/data/reusables/actions/jobs/section-defining-outputs-for-jobs.md +++ b/data/reusables/actions/jobs/section-defining-outputs-for-jobs.md @@ -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