Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explain how to use environment variables in a test matrix #1254

Merged
merged 9 commits into from
Nov 20, 2020
31 changes: 31 additions & 0 deletions content/actions/reference/workflow-syntax-for-github-actions.md
Original file line number Diff line number Diff line change
Expand Up @@ -876,6 +876,37 @@ strategy:

{% endnote %}

##### Using environment variables in a matrix
martin389 marked this conversation as resolved.
Show resolved Hide resolved

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 {% raw %}`env: ${{ matrix.env }}`{% endraw %} 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
site: "prod"
datacenter: "site-a"
- node-version: 12.x
site: "dev"
datacenter: "site-b"
steps:
- name: Echo site details
env:
SITE: ${{ matrix.site }}
DATACENTER: ${{ matrix.datacenter }}
run: echo $SITE $DATACENTER
```
{% endraw %}

### **`jobs.<job_id>.strategy.fail-fast`**

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