Hey GitHub Actions experts,
After reading the docs around matrix in workflow syntax , I was wondering if it’s possible to reference another context inside matrix.
It can be pretty useful if I need to use some information about the commit when constructing the matrix section. Apart from that, sometimes, it’s also possible that one field in the matrix section relies on another field in the same matrix def.
my_job:
strategy:
matrix:
field1: [val1, val2, val3]
field2: [join({{ matrix.field1 }}, 'suffix1'), join({{ matrix.field1 }}, 'suffix2')]
max-parallel: 2
steps:
...
I’ve tried myself with a simple workflow as below, and it doesn’t work. Has anyone had the same idea before?
name: reference-context-inside-matrix
on: [push]
jobs:
build:
strategy:
matrix:
fruit: ['apple', 'banana']
workflow: ${{ github.workflow }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Run a one-line script
run: echo Hello, world, ${{ matrix.fruit }}
- name: Run a one-line script
run: echo Hello, world, ${{ matrix.workflow }}