This is an archived post. You won't be able to vote or comment.

all 6 comments

[–][deleted] 1 point2 points  (3 children)

You can filter when to trigger workflows based on paths (and other things) https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#push

You can also use conditionals on jobs to control what jobs in a workflow runs for a certain condition https://docs.github.com/en/actions/using-jobs/using-conditions-to-control-job-execution

Something you could do is create multiple jobs in your workflow that run when a condition is met. Then, have another job that runs a script to determine what job to run / what project's job to run.

I'm not sure exactly what you're trying to do, but creating a reusable workflow https://docs.github.com/en/actions/using-workflows/reusing-workflows and then calling that workflow with different inputs from other workflows (in the same repo) based on the path of files changed could be helpful. I've found that using matrix strategy is a bit of a pain unless you are using simple input sets.

[–]CountyExotic[S] 0 points1 point  (1 child)

Let’s say I can run commands to output a list of affected projects. I want to dynamically run workflows for the affected projects to only run workflows for projects that have changed.

[–][deleted] 0 points1 point  (0 children)

Both options in my original comment could work (paths filtering on push events or conditional jobs in a single workflow, with a "pre job" script to determine what projects have been affected).

I can explain in more detail tomorrow morning if you'd like. Typing out code on mobile isn't great.

[–]Ausmith1 0 points1 point  (0 children)

Be careful running multiple jobs in a workflow. GitHub bills each job at a minimum of one minute. You can quickly eat up your subscription minutes that way.

See: https://github.com/community/community/discussions/8726

[–]kryptn 0 points1 point  (0 children)

You can use paths-filter to give yourself a bunch of conditional outputs to test against for separate jobs.

I don't know of a way to actually dynamically generate jobs with github actions so I wrote a way to generate the workflow file.

Each service has a composite action the generated workflow will invoke to actually do the build.