DEV Community

Sean Killeen
Sean Killeen

Posted on • Originally published at seankilleen.com on

How To Specify Pairs of Items in GitHub Actions Matrix Strategies

Came across this and wasn’t aware of it (though it makes total sense in retrospect), so I figured I’d pass the tip along.

Background: What is a Matrix Strategy in GitHub Actions?

Sometimes you need an GitHub Action Job to run for multiple combinations of items. In my case, I was looking to run an action to publish a Docker container across a combination of Ruby, Node, and GitHub Pages versions.

Running an action in this way will create an instance of that job for every combination in the matrix entries:

jobs:
  build_release:
    name: "Build and Release"
    strategy:
      matrix:
        RUBY_VERSION: [2.7.3]
        NODE_MAJOR_VERSION: [16, 18]
        GITHUB_PAGES_VERSION: [226]
    runs-on: ubuntu-latest
    env:

      RUBY_VERSION: ${{ matrix.RUBY_VERSION }}
      NODE_MAJOR_VERSION: ${{ matrix.NODE_MAJOR_VERSION }}
      GITHUB_PAGES_VERSION: ${{ matrix.GITHUB_PAGES_VERSION }}

Enter fullscreen mode Exit fullscreen mode

…But do we really want every combination?

Read the rest of this article at SeanKilleen.com!

Speedy emails, satisfied customers

Postmark Image

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay