From 056cd701d55383364f1395799b60344b293aa1aa Mon Sep 17 00:00:00 2001 From: Annie Streater <12902836+streats@users.noreply.github.com> Date: Wed, 9 Aug 2023 21:53:40 +0100 Subject: [PATCH] Added code annotations to "Workflow example" reusable (#39735) Co-authored-by: streats Co-authored-by: Sarah Edwards Co-authored-by: Siara <108543037+SiaraMist@users.noreply.github.com> --- .../understanding-github-actions.md | 1 + .../using-workflows/about-workflows.md | 1 + .../workflow-basic-example-and-explanation.md | 141 +++--------------- 3 files changed, 20 insertions(+), 123 deletions(-) diff --git a/content/actions/learn-github-actions/understanding-github-actions.md b/content/actions/learn-github-actions/understanding-github-actions.md index db0990218cbc..198adeb2f2dd 100644 --- a/content/actions/learn-github-actions/understanding-github-actions.md +++ b/content/actions/learn-github-actions/understanding-github-actions.md @@ -15,6 +15,7 @@ versions: type: overview topics: - Fundamentals +layout: inline --- {% data reusables.actions.enterprise-github-hosted-runners %} diff --git a/content/actions/using-workflows/about-workflows.md b/content/actions/using-workflows/about-workflows.md index f63a9ba5dd50..a22ab3afa31f 100644 --- a/content/actions/using-workflows/about-workflows.md +++ b/content/actions/using-workflows/about-workflows.md @@ -13,6 +13,7 @@ redirect_from: - /actions/using-workflows/advanced-workflow-features topics: - Workflows +layout: inline --- ## About workflows diff --git a/data/reusables/actions/workflow-basic-example-and-explanation.md b/data/reusables/actions/workflow-basic-example-and-explanation.md index db6dcef89b57..94ab06143ac7 100644 --- a/data/reusables/actions/workflow-basic-example-and-explanation.md +++ b/data/reusables/actions/workflow-basic-example-and-explanation.md @@ -33,149 +33,44 @@ Your new {% data variables.product.prodname_actions %} workflow file is now inst To help you understand how YAML syntax is used to create a workflow file, this section explains each line of the introduction's example: - - - - - - - - - -{%- ifversion actions-run-name %} - - - - -{%- endif %} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CodeExplanation
- - ```yaml - name: learn-github-actions - ``` - - - Optional - The name of the workflow as it will appear in the "Actions" tab of the {% data variables.product.prodname_dotcom %} repository. -
+```yaml annotate copy +# Optional - The name of the workflow as it will appear in the "Actions" tab of the {% data variables.product.prodname_dotcom %} repository. If this field is omitted, the name of the workflow file will be used instead. +name: learn-github-actions - ```yaml - run-name: {% raw %}${{ github.actor }}{% endraw %} is learning GitHub Actions - ``` +{%- ifversion actions-run-name %} +# Optional - The name for workflow runs generated from the workflow, which will appear in the list of workflow runs on your repository's "Actions" tab. This example uses an expression with the `github` context to display the username of the actor that triggered the workflow run. For more information, see "[AUTOTITLE](/actions/using-workflows/workflow-syntax-for-github-actions#run-name)." +run-name: {% raw %}${{ github.actor }}{% endraw %} is learning GitHub Actions +{%- endif %} - +# Specifies the trigger for this workflow. This example uses the `push` event, so a workflow run is triggered every time someone pushes a change to the repository or merges a pull request. This is triggered by a push to every branch; for examples of syntax that runs only on pushes to specific branches, paths, or tags, see "[AUTOTITLE](/actions/reference/workflow-syntax-for-github-actions#onpushpull_requestpull_request_targetpathspaths-ignore)." +on: [push] - Optional - The name for workflow runs generated from the workflow, which will appear in the list of workflow runs on your repository's "Actions" tab. This example uses an expression with the `github` context to display the username of the actor that triggered the workflow run. For more information, see "[AUTOTITLE](/actions/using-workflows/workflow-syntax-for-github-actions#run-name)." -
- - ```yaml - on: [push] - ``` - - -Specifies the trigger for this workflow. This example uses the push event, so a workflow run is triggered every time someone pushes a change to the repository or merges a pull request. This is triggered by a push to every branch; for examples of syntax that runs only on pushes to specific branches, paths, or tags, see "Workflow syntax for {% data variables.product.prodname_actions %}." -
- - ```yaml +# Groups together all the jobs that run in the `learn-github-actions` workflow. jobs: - ``` - - - Groups together all the jobs that run in the learn-github-actions workflow. -
- ```yaml +# Defines a job named `check-bats-version`. The child keys will define properties of the job. check-bats-version: - ``` - - -Defines a job named check-bats-version. The child keys will define properties of the job. -
- ```yaml +# Configures the job to run on the latest version of an Ubuntu Linux runner. This means that the job will execute on a fresh virtual machine hosted by GitHub. For syntax examples using other runners, see "[AUTOTITLE](/actions/reference/workflow-syntax-for-github-actions#jobsjob_idruns-on)" runs-on: ubuntu-latest - ``` - - Configures the job to run on the latest version of an Ubuntu Linux runner. This means that the job will execute on a fresh virtual machine hosted by GitHub. For syntax examples using other runners, see "Workflow syntax for {% data variables.product.prodname_actions %}." -
- - ```yaml +# Groups together all the steps that run in the `check-bats-version` job. Each item nested under this section is a separate action or shell script. steps: - ``` - - - Groups together all the steps that run in the check-bats-version job. Each item nested under this section is a separate action or shell script. -
- ```yaml +# The `uses` keyword specifies that this step will run `v3` of the `actions/checkout` action. This is an action that checks out your repository onto the runner, allowing you to run scripts or other actions against your code (such as build and test tools). You should use the checkout action any time your workflow will use the repository's code. - uses: {% data reusables.actions.action-checkout %} - ``` - - -The uses keyword specifies that this step will run v3 of the actions/checkout action. This is an action that checks out your repository onto the runner, allowing you to run scripts or other actions against your code (such as build and test tools). You should use the checkout action any time your workflow will run against the repository's code. -
- ```yaml +# This step uses the `{% data reusables.actions.action-setup-node %}` action to install the specified version of the Node.js. (This example uses version 14.) This puts both the `node` and `npm` commands in your `PATH`. - uses: {% data reusables.actions.action-setup-node %} with: node-version: '14' - ``` - - This step uses the {% data reusables.actions.action-setup-node %} action to install the specified version of the Node.js (this example uses v14). This puts both the node and npm commands in your PATH. -
- - ```yaml +# The `run` keyword tells the job to execute a command on the runner. In this case, you are using `npm` to install the `bats` software testing package. - run: npm install -g bats - ``` - - - The run keyword tells the job to execute a command on the runner. In this case, you are using npm to install the bats software testing package. -
- ```yaml +# Finally, you'll run the `bats` command with a parameter that outputs the software version. - run: bats -v - ``` - - - Finally, you'll run the bats command with a parameter that outputs the software version. -
+``` ### Visualizing the workflow file