Skip to content
Discussion options

You must be logged in to vote

This is a known GitHub Actions security behavior: secrets should never be used directly in matrix strategy variables because the matrix values are interpolated into job metadata (names, etc.) before secret masking is applied. Secret masking only works on the actual job logs, not on the job's metadata properties.

Solution:

  1. Move secrets out of matrix: Don't use secrets in matrix.include or strategy definitions
strategy:
  matrix:
    node-version: [16, 18, 20]  # ✓ Safe
    # environment: [dev, prod]  # ✗ Don't put secrets here

steps:
  - name: Use secret safely in step
    env:
      DEPLOY_TOKEN: ${{ secrets.DEPLOY_TOKEN }}
    run: |
      # Secret is only in environment, masked in logs

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by augustbreay
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Actions Build, test, and automate your deployment pipeline with world-class CI/CD Question Ask and answer questions about GitHub features and usage source:ui Discussions created via Community GitHub templates
4 participants