Skip to content

Commit dc3a572

Browse files
authored
repo sync
2 parents 20a84e9 + c9293f4 commit dc3a572

3 files changed

Lines changed: 34 additions & 27 deletions

File tree

content/actions/learn-github-actions/migrating-from-travis-ci-to-github-actions.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,12 @@ git:
164164
</tr>
165165
</table>
166166
167+
#### Using environment variables in a matrix
168+
169+
Travis CI and {% data variables.product.prodname_actions %} can both add custom environment variables to a test matrix, which allows you to refer to the variable in a later step.
170+
171+
In {% data variables.product.prodname_actions %}, you can use the `include` key to add custom environment variables to a matrix. {% data reusables.github-actions.matrix-variable-example %}
172+
167173
### Key features in {% data variables.product.prodname_actions %}
168174

169175
When migrating from Travis CI, consider the following key features in {% data variables.product.prodname_actions %}:

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

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -878,34 +878,9 @@ strategy:
878878

879879
##### Using environment variables in a matrix
880880

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.
881+
You can add custom environment variables for each test combination by using the `include` key. You can then refer to the custom environment variables in a later step.
882882

883-
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:
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-
site: "prod"
897-
datacenter: "site-a"
898-
- node-version: 12.x
899-
site: "dev"
900-
datacenter: "site-b"
901-
steps:
902-
- name: Echo site details
903-
env:
904-
SITE: ${{ matrix.site }}
905-
DATACENTER: ${{ matrix.datacenter }}
906-
run: echo $SITE $DATACENTER
907-
```
908-
{% endraw %}
883+
{% data reusables.github-actions.matrix-variable-example %}
909884

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
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:
2+
3+
{% raw %}
4+
```yaml
5+
name: Node.js CI
6+
on: [push]
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
strategy:
11+
matrix:
12+
include:
13+
- node-version: 10.x
14+
site: "prod"
15+
datacenter: "site-a"
16+
- node-version: 12.x
17+
site: "dev"
18+
datacenter: "site-b"
19+
steps:
20+
- name: Echo site details
21+
env:
22+
SITE: ${{ matrix.site }}
23+
DATACENTER: ${{ matrix.datacenter }}
24+
run: echo $SITE $DATACENTER
25+
```
26+
{% endraw %}

0 commit comments

Comments
 (0)