Skip to content

beacon-biosignals/matrix-output

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ac86c14 · Aug 14, 2024

History

31 Commits
Aug 14, 2024
Aug 13, 2024
Aug 13, 2024
Aug 14, 2024

Repository files navigation

Matrix Output

Collect outputs from each matrix job. Currently, setting output for matrix jobs will cause outputs of earlier completed jobs to be overwritten by jobs completed later (see discussion). This action allows the output from each matrix job to be collected into a JSON list to be utilized by dependent jobs.

The matrix-output job is intended to only be used once per job. Attempting to utilize this action multiple times within the same job will cause the second use of this action to fail.

Examples

# CI.yaml
jobs:
  build:
    name: Build ${{ matrix.build.name }}
    # These permissions are needed to:
    # - Use `matrix-output`: https://github.com/beacon-biosignals/matrix-output#permissions
    permissions:
      actions: read
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        build:
          - name: App One
            repo: user/app1
          - name: App Two
            repo: user/app2
    outputs:
      json: ${{ steps.matrix-output.outputs.json }}
    steps:
      - uses: docker/build-push-action@v6
        id: build-push
        with:
          tags: ${{ matrix.build.repo }}:latest
          push: true
      - uses: beacon-biosignals/matrix-output@v1
        id: matrix-output
        with:
          yaml: |
            name: ${{ matrix.build.name }}
            image: ${{ matrix.build.repo }}@${{ steps.build-push.outputs.digest }}

  test:
    name: Test ${{ matrix.build.name }}
    needs: build
    runs-on: ubuntu-latest
    container:
      image: ${{ matrix.build.image }}
    strategy:
      fail-fast: false
      matrix:
        build: ${{ fromJSON(needs.build.outputs.json) }}
    steps:
      ...

Inputs

The matrix-output action supports the following inputs:

Name Description Required Example
yaml A string representing a YAML data. Typically, a simple dictionary of key/value pairs. Yes
name: ${{ matrix.name }}
...

Outputs

Name Description Example
json A string representing a JSON list of dictionaries. Each dictionary in the list contains the output for a single job from the job matrix. The order of this list corresponds to the job index (i.e. strategy.job-index).
[
  {
    "name": "Server.jl",
    ...
  },
  {
    "name": "Client.jl",
    ...
  }
]

Permissions

The follow job permissions are required to run this action:

permissions: {}