Expose `strategy` and `matrix` variables in `context`

Aperta
#615 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
github-actions, javascript, typescript
Ambito
ci-cd, tooling

Direzione di ricerca

Start with actions/github-script@v7 and trace how the script receives its context object, then compare the available GitHub Actions strategy and matrix values with the requested names. Done means workflow scripts can access the requested values through context, with tests or examples covering matrix and strategy usage.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Is your feature request related to a problem? Please describe.

I'm using a matrix and I want to access matrix- and strategy-related variables in my github-script. The two ways to do that are:

  1. Setting env vars:
# ...
strategy:
  matrix:
    group: [1, 2]
steps:
  - uses: actions/github-script@v7
    env:
      MATRIX_GROUP: ${{ matrix.group }}
      MATRIX_NUM_GROUPS: ${{ strategy.job-total }}
    with:
      script: |
        const group = parseInt(process.env.MATRIX_GROUP)
        const numGroups = parseInt(process.env.MATRIX_NUM_GROUPS)
  1. Interpolation:
# ...
strategy:
  matrix:
    group: [1, 2]
steps:
  - uses: actions/github-script@v7
    with:
      script: |
        const group = ${{ matrix.group }}
        const numGroups = ${{ strategy.job-total }}

Describe the solution you'd like
It would be nice if these were offered somewhere in the context object, which seems like an intuitive home for them. Something like...

# ...
strategy:
  matrix:
    group: [1, 2]
steps:
  - uses: actions/github-script@v7
    with:
      script: |
        const group = parseInt(context.strategy.matrix.group)
        const numGroups = context.strategy.totalJobs
Lingua principale
TypeScript
Stelle
5k
Fork
586
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di actions/github-script

Tutte le issue di actions/github-script

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.