Skip to content

Commit 0418bda

Browse files
authored
Update workflow-syntax-for-github-actions.md
1 parent 4bf4e55 commit 0418bda

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

content/actions/reference/workflow-syntax-for-github-actions.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -876,6 +876,37 @@ strategy:
876876

877877
{% endnote %}
878878

879+
##### Using environment variables in a matrix
880+
881+
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.
882+
883+
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:
884+
885+
{% raw %}
886+
```yaml
887+
name: Node.js CI
888+
on: [push]
889+
jobs:
890+
build:
891+
runs-on: ubuntu-latest
892+
strategy:
893+
matrix:
894+
include:
895+
- node-version: 10.x
896+
env:
897+
site: "prod"
898+
datacenter: "site-a"
899+
- node-version: 12.x
900+
env:
901+
site: "dev"
902+
datacenter: "site-b"
903+
steps:
904+
- name: Echo site details
905+
env: ${{ matrix.env }}
906+
run: echo $site $datacenter
907+
```
908+
{% endraw %}
909+
879910
### **`jobs.<job_id>.strategy.fail-fast`**
880911

881912
When set to `true`, {% data variables.product.prodname_dotcom %} cancels all in-progress jobs if any `matrix` job fails. Default: `true`

0 commit comments

Comments
 (0)