Giter Club home page Giter Club logo

gha-sequential-matrix's Introduction

Dynamically constructed matrix strategy

This repo shows a simple example of how you can dynamically construct a matrix strategy with GitHub Actions.

The example uses workflow_dispatch to allow the workflow to be executed manually with some inputs, just to easily demonstrate the mechanism:

workflow inputs

When the default inputs are selected, the workflow will dynamically construct a strategy matrix in JSON during the execution of the First Job. The JSON will be taken as an output from the first job and used as the value for the strategy: key of the Second Job. It uses fromJSON to take the JSON string and parse it into something GitHub Actions can understand.

The result is the following being dynamically constructed:

strategy:
  matrix:
    stage: ["dev", "tst"]
  fail-fast: true
  max-parallel: 1

This results in an ordered execution of the required stages, due to the max-parallel being defined as 1.

jobs in order

Setting fail-fast to true (default) causes GitHib Actions to cancel all matrix in-progress or queued jobs. Which would mean, in this example, that if dev fails then tst will not run.

not max-parallel constrained

If Run in order is unchecked then the Second Job is not constrained to max-parallel: 1 and normal parallel job execution takes place:

parallel jobs

This also allows for the stage values to be dynamically constructed. So, for example, we could uncheck Run Dev:

uncheck dev

would construct the matrix as follows:

strategy:
  matrix:
    stage: ["tst"]
  fail-fast: false
  max-parallel: 2

Obviously meaning that only the tst environment will be processed in this workflow execution.

no dev no order

This is only a simple example but you can imagine you could construct quite a complex matrix strategy if so desired.

gha-sequential-matrix's People

Contributors

tonyskidmore avatar

Watchers

James Cloos avatar  avatar  avatar

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.