GithubActionsでマトリックス



## Matrix
- GithubActionsでは、1つのジョブ内で特定の変数をキーに複数のジョブを実行することができる
- ループに近いがたぶん少し違う
- 冗長になってしまいがちな部分はこれを使うと結構すっきりする（と思う）


## サンプル
```yaml
name: test-matrix

on:
  workflow_dispatch:

jobs:
  job-matrix:
    strategy:
      matrix:
        env: [dev, stg, prd]
    runs-on: ubuntu-latest

    steps:
    - run: echo ${{ matrix.env }}
```

## 実行結果

```
act -P ubuntu-latest=nektos/act-environments-ubuntu:18.04-lite workflow_dispatch -j 'job-matrix'                                      [test-matrix/job-matrix-1] 🚀  Start image=nektos/act-environments-ubuntu:18.04-lite
[test-matrix/job-matrix-2] 🚀  Start image=nektos/act-environments-ubuntu:18.04-lite
[test-matrix/job-matrix-3] 🚀  Start image=nektos/act-environments-ubuntu:18.04-lite
[test-matrix/job-matrix-3]   🐳  docker pull image=nektos/act-environments-ubuntu:18.04-lite platform= username= forcePull=false
[test-matrix/job-matrix-2]   🐳  docker pull image=nektos/act-environments-ubuntu:18.04-lite platform= username= forcePull=false
[test-matrix/job-matrix-1]   🐳  docker pull image=nektos/act-environments-ubuntu:18.04-lite platform= username= forcePull=false
[test-matrix/job-matrix-3]   🐳  docker create image=nektos/act-environments-ubuntu:18.04-lite platform= entrypoint=["/usr/bin/tail" "-f" "/dev/null"] cmd=[]
[test-matrix/job-matrix-2]   🐳  docker create image=nektos/act-environments-ubuntu:18.04-lite platform= entrypoint=["/usr/bin/tail" "-f" "/dev/null"] cmd=[]
[test-matrix/job-matrix-1]   🐳  docker create image=nektos/act-environments-ubuntu:18.04-lite platform= entrypoint=["/usr/bin/tail" "-f" "/dev/null"] cmd=[]
[test-matrix/job-matrix-3]   🐳  docker run image=nektos/act-environments-ubuntu:18.04-lite platform= entrypoint=["/usr/bin/tail" "-f" "/dev/null"] cmd=[]
[test-matrix/job-matrix-2]   🐳  docker run image=nektos/act-environments-ubuntu:18.04-lite platform= entrypoint=["/usr/bin/tail" "-f" "/dev/null"] cmd=[]
[test-matrix/job-matrix-1]   🐳  docker run image=nektos/act-environments-ubuntu:18.04-lite platform= entrypoint=["/usr/bin/tail" "-f" "/dev/null"] cmd=[]
[test-matrix/job-matrix-1] 🧪  Matrix: map[env:dev]
[test-matrix/job-matrix-2] 🧪  Matrix: map[env:stg]
[test-matrix/job-matrix-3] 🧪  Matrix: map[env:prd]
[test-matrix/job-matrix-2] ⭐ Run Main echo ${{ matrix.env }}
[test-matrix/job-matrix-3] ⭐ Run Main echo ${{ matrix.env }}
[test-matrix/job-matrix-1] ⭐ Run Main echo ${{ matrix.env }}
[test-matrix/job-matrix-3]   🐳  docker exec cmd=[bash --noprofile --norc -e -o pipefail /var/run/act/workflow/0] user= workdir=
[test-matrix/job-matrix-1]   🐳  docker exec cmd=[bash --noprofile --norc -e -o pipefail /var/run/act/workflow/0] user= workdir=
[test-matrix/job-matrix-2]   🐳  docker exec cmd=[bash --noprofile --norc -e -o pipefail /var/run/act/workflow/0] user= workdir=
| prd
| dev
| stg
[test-matrix/job-matrix-1]   ✅  Success - Main echo ${{ matrix.env }}
[test-matrix/job-matrix-3]   ✅  Success - Main echo ${{ matrix.env }}
[test-matrix/job-matrix-2]   ✅  Success - Main echo ${{ matrix.env }}
[test-matrix/job-matrix-3] 🏁  Job succeeded
[test-matrix/job-matrix-1] 🏁  Job succeeded
[test-matrix/job-matrix-2] 🏁  Job succeeded
```


## 参考
https://docs.github.com/ja/actions/using-jobs/using-a-matrix-for-your-jobs