Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • Always use a matrix for versions like Python/Django, even if there’s only one. This makes it easier to understand and adjust the versions.

Dynamic Matrix

To dynamically set matrix values in a maintainable way, you can utilize https://github.com/actions/github-script

Code Block
languageyaml
jobs:
  setup-matrix:
    steps:
      - uses: actions/github-script@v6
        id: generate_matrix
        with:
          script: |
            var nodeVersions = [16, 18];
            // logic to add/remove node versions
            core.setOutput('nodeVersions', nodeVersions);
    outputs:
      node_versions: ${{ steps.generate_matrix.outputs.nodeVersions }}

  run_tests:
    needs: [setup-matrix]
    strategy:
      matrix:
        version: ${{ fromJson(needs.setup-matrix.outputs.node_versions) }}
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-node@v3
        with:
          node-version: ${{ matrix.version }}
      - run: |
          npm ci
          npm run test

Security

...