From 0418bdadd037ea38d58335b07e156e2c10a08409 Mon Sep 17 00:00:00 2001 From: Martin Lopes <54248166+martin389@users.noreply.github.com> Date: Wed, 11 Nov 2020 15:47:46 +1000 Subject: [PATCH 1/5] Update workflow-syntax-for-github-actions.md --- .../workflow-syntax-for-github-actions.md | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/content/actions/reference/workflow-syntax-for-github-actions.md b/content/actions/reference/workflow-syntax-for-github-actions.md index 2d4d9a44dfb1..a620d3fd93fa 100644 --- a/content/actions/reference/workflow-syntax-for-github-actions.md +++ b/content/actions/reference/workflow-syntax-for-github-actions.md @@ -876,6 +876,37 @@ strategy: {% endnote %} +##### Using environment variables in a matrix + +You can add custom environment variables for each test combination by using `include` with `env`. You can then refer to the custom environment variables in a later step. + +In this example, the included matrix entries for `node-version` are able to use different values in their environment variables. The `Echo site details` step then uses `env: ${{ matrix.env }}` to refer to the custom variables: + +{% raw %} +```yaml +name: Node.js CI +on: [push] +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + include: + - node-version: 10.x + env: + site: "prod" + datacenter: "site-a" + - node-version: 12.x + env: + site: "dev" + datacenter: "site-b" + steps: + - name: Echo site details + env: ${{ matrix.env }} + run: echo $site $datacenter +``` +{% endraw %} + ### **`jobs..strategy.fail-fast`** When set to `true`, {% data variables.product.prodname_dotcom %} cancels all in-progress jobs if any `matrix` job fails. Default: `true` From fc18c04fb35040e775108bea7f7bb1d24a3f590b Mon Sep 17 00:00:00 2001 From: Martin Lopes <54248166+martin389@users.noreply.github.com> Date: Wed, 11 Nov 2020 17:31:13 +1000 Subject: [PATCH 2/5] Added some light rephrasing --- content/actions/reference/workflow-syntax-for-github-actions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/actions/reference/workflow-syntax-for-github-actions.md b/content/actions/reference/workflow-syntax-for-github-actions.md index a620d3fd93fa..552c27bc3238 100644 --- a/content/actions/reference/workflow-syntax-for-github-actions.md +++ b/content/actions/reference/workflow-syntax-for-github-actions.md @@ -880,7 +880,7 @@ strategy: You can add custom environment variables for each test combination by using `include` with `env`. You can then refer to the custom environment variables in a later step. -In this example, the included matrix entries for `node-version` are able to use different values in their environment variables. The `Echo site details` step then uses `env: ${{ matrix.env }}` to refer to the custom variables: +In this example, the matrix entries for `node-version` are each configured to use different environment variables. The `Echo site details` step then uses `env: ${{ matrix.env }}` to refer to the custom variables: {% raw %} ```yaml From 6c8e37953837ac20f5f250d43703e90b3c39f762 Mon Sep 17 00:00:00 2001 From: Martin Lopes <54248166+martin389@users.noreply.github.com> Date: Wed, 11 Nov 2020 17:49:02 +1000 Subject: [PATCH 3/5] Update workflow-syntax-for-github-actions.md --- content/actions/reference/workflow-syntax-for-github-actions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/actions/reference/workflow-syntax-for-github-actions.md b/content/actions/reference/workflow-syntax-for-github-actions.md index 552c27bc3238..68bb8b5c6dea 100644 --- a/content/actions/reference/workflow-syntax-for-github-actions.md +++ b/content/actions/reference/workflow-syntax-for-github-actions.md @@ -880,7 +880,7 @@ strategy: You can add custom environment variables for each test combination by using `include` with `env`. You can then refer to the custom environment variables in a later step. -In this example, the matrix entries for `node-version` are each configured to use different environment variables. The `Echo site details` step then uses `env: ${{ matrix.env }}` to refer to the custom variables: +In this example, the matrix entries for `node-version` are each configured to use different values for the `site` and `datacenter` environment variables. The `Echo site details` step then uses `env: ${{ matrix.env }}` to refer to the custom variables: {% raw %} ```yaml From dc36bcb91c8a109ec730817a4b72ca96ffcc390c Mon Sep 17 00:00:00 2001 From: Martin Lopes <54248166+martin389@users.noreply.github.com> Date: Thu, 19 Nov 2020 17:55:21 +1000 Subject: [PATCH 4/5] Updated example based on feedback --- .../workflow-syntax-for-github-actions.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/content/actions/reference/workflow-syntax-for-github-actions.md b/content/actions/reference/workflow-syntax-for-github-actions.md index 68bb8b5c6dea..9f2a9899fdac 100644 --- a/content/actions/reference/workflow-syntax-for-github-actions.md +++ b/content/actions/reference/workflow-syntax-for-github-actions.md @@ -893,17 +893,17 @@ jobs: matrix: include: - node-version: 10.x - env: - site: "prod" - datacenter: "site-a" + site: "prod" + datacenter: "site-a" - node-version: 12.x - env: - site: "dev" - datacenter: "site-b" + site: "dev" + datacenter: "site-b" steps: - name: Echo site details - env: ${{ matrix.env }} - run: echo $site $datacenter + env: + SITE: ${{ matrix.site }} + DATACENTER: ${{ matrix.datacenter }} + run: echo $SITE $DATACENTER ``` {% endraw %} From c787a53c6dd77c14575e3f07f13c640423f18df6 Mon Sep 17 00:00:00 2001 From: Martin Lopes <54248166+martin389@users.noreply.github.com> Date: Fri, 20 Nov 2020 16:01:38 +1000 Subject: [PATCH 5/5] Apply suggestions from code review Co-authored-by: Lucas Costi --- content/actions/reference/workflow-syntax-for-github-actions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/actions/reference/workflow-syntax-for-github-actions.md b/content/actions/reference/workflow-syntax-for-github-actions.md index 43544f3f4771..32a0b64e5390 100644 --- a/content/actions/reference/workflow-syntax-for-github-actions.md +++ b/content/actions/reference/workflow-syntax-for-github-actions.md @@ -880,7 +880,7 @@ strategy: You can add custom environment variables for each test combination by using `include` with `env`. You can then refer to the custom environment variables in a later step. -In this example, the matrix entries for `node-version` are each configured to use different values for the `site` and `datacenter` environment variables. The `Echo site details` step then uses `env: ${{ matrix.env }}` to refer to the custom variables: +In this example, the matrix entries for `node-version` are each configured to use different values for the `site` and `datacenter` environment variables. The `Echo site details` step then uses {% raw %}`env: ${{ matrix.env }}`{% endraw %} to refer to the custom variables: {% raw %} ```yaml