1

I'm making a JavaScript API for a .NET project. So I need GitHub actions to have both Node.JS and .NET Core (2.1, 2.2, 3.0 or 3.1) installed. Is this possible?

This is my GitHub actions config YAML file:

# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Node.js CI

on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]

jobs:
  build:

    runs-on: ubuntu-latest

    strategy:
      matrix:
        node-version: [10.x, 12.x, 14.x]

    steps:
    - uses: actions/checkout@v2
    - name: Use Node.js ${{ matrix.node-version }}
      uses: actions/setup-node@v1
      with:
        node-version: ${{ matrix.node-version }}
    - run: npm ci
    - run: npm run build
    - run: npm test

1 Answer 1

1

Yes, this is possible, you can have multiple matrix arguments:

name: Node.js CI

on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]

jobs:
  build:

    runs-on: ubuntu-latest

    strategy:
      matrix:
        node-version: [10.x, 12.x, 14.x]
        dotnet: [ '2.1.811', '2.2.103', '3.0', '3.1.x' ]

    steps:
    - uses: actions/checkout@v2
    - name: Use Node.js ${{ matrix.node-version }}
      uses: actions/setup-node@v1
      with:
        node-version: ${{ matrix.node-version }}
    - name: Setup dotnet
      uses: actions/setup-dotnet@v1
      with:
        dotnet-version: ${{ matrix.dotnet }}
    - run: npm ci
    - run: npm run build
    - run: npm test
    - run: dotnet build <my project>
Sign up to request clarification or add additional context in comments.

1 Comment

Is it also possible to have multiple with arguments. with: dotnet-version: ${{ matrix.dotnet }} node-version: ${{ matrix.node-version }}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.