1
0
mirror of synced 2025-12-25 20:02:09 -05:00
Files
docs/data/reusables/github-actions/matrix-variable-example.md
Martin Lopes c9293f4f90 Travis migration: Add new section "Using environment variables in a matrix" (#16606)
* Added new section "Using environment variables in a matrix"

* Small fixes

* Moved example into reusable

* Apply suggestions from code review

Co-authored-by: Lucas Costi <lucascosti@users.noreply.github.com>

Co-authored-by: Lucas Costi <lucascosti@users.noreply.github.com>
2020-11-24 16:59:31 +10:00

768 B

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 %}

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 %}