actions / actions/toolkit

Cannot access matrix inside `if`

Open
#1,111 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
TypeScript
Stars
5.9k
Forks
1.8k
PR merge metrics
No merged PRs in 30d

Description

Describe the bug
Cannot access matrix inside if in jobs.

To Reproduce
Steps to reproduce the behavior:

# workflow.yml

name: CI

on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]
  workflow_dispatch:

jobs:
  build:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        module: ['admin', 'server']
    if: ${{ contains('admin', matrix.module) }}

    steps:
      - name: Run a one-line script
        run: echo Hello, world!

When I run this action, i got an error like below.
image

Expected behavior
I can access to 'matrix' in if. In docs,

You can access this context from any job or step in a workflow.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the workflow.yml reproduction and the linked matrix-context documentation, focusing on the job-level if expression and its access to matrix.module. Verify whether the documented context availability matches the observed error. Done means the behavior is clarified and the workflow either works as expected or the documentation accurately describes the limitation.

Written by the indexing model from the issue text.

Assessment

Tech stack
github-actions
Domain
ci-cd
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.