Lukas Rieger
Lukas Rieger

Reputation: 786

GitHub Actions: can I dynamically generate and run a child workflow?

We are migrating from gitlab to github.

With gitlab pipelines I am checking the repository and dynamically generating a child pipeline with the actual jobs to run. This is easiest explained by the actual definition:

stages:
    - bootstrap
    - run


    
# ---------------------------------------------------------------------------
# Bootstrap
# ---------------------------------------------------------------------------

bootstrap:
    stage: bootstrap
    # this will write the file jobs.yml to disk
    script: ./bootstrap.ps1

    artifacts:
        paths:
            - artifacts/jobs.yml



# ---------------------------------------------------------------------------
# Run
# ---------------------------------------------------------------------------

run:
    stage: run
    trigger:
        include:
            - artifact: artifacts/jobs.yml
              job: bootstrap
        strategy: depend

Is there anything similar in github actions? I found that it's possible to dynamically generate a matrix, but that is not enough.

I need to run jobs that depend on each other and run in parallel/sequence.

Example:

enter image description here

This whole job graph is dynamically generated.

Here I'd have three stages where all the app jobs run in parallel, and the single deploy job waits for all app jobs to complete.

I also need to pass outputs from the app jobs to the deploy job, which also seems to not really work with a matrix: https://github.com/github-community/community/discussions/17245

even if the output is set by multiple matrix variations of the job, only one is retained.


So, actual question is there a way to generate a workflow with multiple interdependent jobs on the fly and execute it, or is this something that just doesn't exist?

Upvotes: 12

Views: 2472

Answers (1)

sagstetterC
sagstetterC

Reputation: 92

No, but you can trigger multiple interdependet already exsiting workflows (on the fly). create in the bootstrap job a list of workflows names paired with the info if the workflow needs to be trigger or not. And in the run job use this list to trigger the workflows.

Upvotes: 0

Related Questions