diff --git a/.github/workflows/create_zip.yaml b/.github/workflows/create_zip.yaml index de0284d..d21f568 100644 --- a/.github/workflows/create_zip.yaml +++ b/.github/workflows/create_zip.yaml @@ -5,6 +5,7 @@ on: - master paths: - "doc/**" + - ".github/workflows/create_zip.yaml" defaults: run: diff --git a/.github/workflows/react-jest.yaml b/.github/workflows/react-jest.yaml index 70fbc55..5ac81a5 100644 --- a/.github/workflows/react-jest.yaml +++ b/.github/workflows/react-jest.yaml @@ -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 diff --git a/doc/fig/matrix_test.png b/doc/fig/matrix_test.png new file mode 100644 index 0000000..93165ca Binary files /dev/null and b/doc/fig/matrix_test.png differ diff --git a/doc/github-actions.md b/doc/github-actions.md index e7de5f6..d4ba638 100644 --- a/doc/github-actions.md +++ b/doc/github-actions.md @@ -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)