Git Product home page Git Product logo

action-workflow-matrix's Introduction

action-workflow-matrix

License

GitHub action to generate build matrix from yaml file

Requirements

  • checkout repository to read the yaml file
- uses: actions/checkout@v2

Usage

- uses: bonddim/action-workflow-matrix@stable
  with:
    matrix-file: "${{ github.workspace }}/.github/workflow-matrix.yml"
    # [optional]
    # The YAML file with matrix. Default is .github/workflow-matrix.yml
    # Action will fail if file not found
    workflow: "${{ github.workflow }}"
    # [optional]
    # Key in the matrix file to get the matrix. Default is '${{ github.workflow }}'
    # Action will generate matrix from default key (matrix) if workflow key is not defined in matrix file
    # Action will generate empty matrix if workflow and matrix keys are not defined in matrix file

Example of .github/workflow-matrix.yml:

---
matrix: &default
  node: [12, 14]
  os: [ubuntu-latest, windows-latest, macos-latest]
  include: &default_icnlude
    - node: 16
      os: ubuntu-latest

# Overwrite parameter
ubuntu:
  matrix:
    <<: *default
    os: [ubuntu-latest]

# Overwrite include
include:
  matrix:
    <<: *default
    include:
      - os: ubuntu-18.04
        node: 10

# Note: All include combinations are processed after exclude. This allows you to use include to add back combinations that were previously excluded.
# https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idstrategymatrix
# Exclude from default matrix
exclude:
  matrix:
    <<: *default
    exclude:
      - os: macos-latest
        node: 12
      - os: windows-latest
        node: 14

# Additional parameters
parameter:
  matrix:
    <<: *default
    experimental: [true]
    foo: [bar]
# This workflow will generate default matrix
name: default

jobs:
  matrix:
    runs-on: ubuntu-latest
    outputs:
      matrix: ${{ steps.set-matrix.outputs.matrix }}
    steps:
      - uses: actions/checkout@v2
      - name: Set build matrix
        id: set-matrix
        uses: bonddim/action-workflow-matrix@stable

  build:
    runs-on: ${{ matrix.os }}
    needs: matrix
    strategy:
      fail-fast: false
      matrix: ${{ fromJson(needs.matrix.outputs.matrix) }}
    steps:
      - name: Dump matrix context
        run: echo "$MATRIX_CONTEXT"
        env:
          MATRIX_CONTEXT: ${{ toJSON(matrix) }}

Check other build examples:

License

MIT

action-workflow-matrix's People

Contributors

bonddim avatar

Forkers

devlynnx

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.