Skip to content

Commit

Permalink
Merge pull request #43 from RyosukeDTomita/feature/try-matrix
Browse files Browse the repository at this point in the history
Feature/try matrix
  • Loading branch information
RyosukeDTomita authored Jul 2, 2024
2 parents 5a92b40 + adee612 commit 805d339
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 5 deletions.
1 change: 1 addition & 0 deletions .github/workflows/create_zip.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
- master
paths:
- "doc/**"
- ".github/workflows/create_zip.yaml"

defaults:
run:
Expand Down
12 changes: 7 additions & 5 deletions .github/workflows/react-jest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,22 @@ jobs:
runs-on: ubuntu-latest
permissions:
contents: read
# デフォルトのワーキングディレクトリのため設定不要だが,明示的に指定。
defaults:
# デフォルトのワーキングディレクトリのため設定不要だが,明示的に指定。
run:
working-directory: /home/runner/work/devsecops-demo-aws-ecs/devsecops-demo-aws-ecs

strategy:
matrix:
node_version: [20, 22]

steps:
# checkout repository to runner
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: set up node20
uses: actions/setup-node@1a4442cacd436585916779262731d5b162bc6ec7 # v3.8.2
- name: set up node
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version: '20'
node-version: ${{ matrix.node_version }}

- name: install package using aqua
uses: aquaproj/aqua-installer@6ce1f8848ec8e61f14d57bd5d7597057a6dd187c # v3.0.1
Expand Down
Binary file added doc/fig/matrix_test.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions doc/github-actions.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,37 @@ jobs:
sarif_file: report.sarif
category: semgrep
```

---

## matrixを使ってジョブを複数実行する

> [jobにmatrixを使用する](https://docs.github.com/ja/actions/using-jobs/using-a-matrix-for-your-jobs)

```yaml
jobs:
frontend-jest: # job id(typed by user)
runs-on: ubuntu-latest
permissions:
contents: read
# デフォルトのワーキングディレクトリのため設定不要だが,明示的に指定。
defaults:
run:
working-directory: /home/runner/work/devsecops-demo-aws-ecs/devsecops-demo-aws-ecs
strategy:
matrix:
node_version: [20, 22]
steps:
# checkout repository to runner
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: set up node
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version: ${{ matrix.node_version }}
```

成功すると以下のような感じになる。

![matrix image](./fig/matrix_test.png)

0 comments on commit 805d339

Please sign in to comment.