#github-actions (2021-10)

Discussions related to GitHub Actions

2021-10-12

toast-gear avatar
toast-gear

has anyone had much luck creating dynamic matrixes?

Error when evaluating 'strategy' for job 'scaling-jobs'. .github/workflows/on_manual_scale.yaml (Line: 48, Col: 17): Error reading JToken from JsonReader. Path '', line 0, position 0.,.github/workflows/on_manual_scale.yaml (Line: 48, Col: 17): Unexpected value ''

my matrix looks like:

echo "Matrix set to :"
echo "[$joined]"
["1","2","3","4","5","6","7","8","9","10"]

my output looks like

echo "::set-output name=matrix::[$joined]"

and my strategy on my downstream job looks like:

    strategy:
        matrix: ${{ fromJson(needs.build-matrix.outputs.matrix) }}
toast-gear avatar
toast-gear

Got it, output was wrong. Its still a bit magic to me though

2021-10-15

Aumkar Prajapati avatar
Aumkar Prajapati

Hi all, I’m trying to figure out if Github Actions is a good fit. So I have built out a POC with a single application and it works great! However I’m dealing with some issues, we basically have a monorepo with a ton of different applications and different namespaces. It’s creating a bit of pain in trying to figure out how Github actions would work.

Basically say we have PR and it’s testing and building a few packages, x/javaAppA, y/javaAppB and z/frontendAppA. Would GitHub actions be able to handle things dynamically like this? I’m having some trouble in figuring this out, so far I have a list of changes with the different paths to things, and am able to build one app individually but not all three together. Any suggestions?

Our current setup uses Jenkins with build.properties files in each app folder to define what sort of language it uses and where it deploys to. I.e java app that deploys to kubernetes, reactJS app that deploys via terraform to AWS s3 / Cloudfront

Darren Cunningham avatar
Darren Cunningham

It can support it, but it’s really hard to be able to provide good insights into how to solve that riddle without explicit knowledge of the teams acceptance criteria.

I will say that generally you can trigger a GitHub Actions for criteria like paths (files that changed in the PR) and match those to a Java build line, or a Node build line, etc. But you might find that this is too limiting and you need to first run an initial pipeline that runs a script in your language of choice and then triggers a second pipeline, to do this you can use repository-dispatch.

You can have multiple workflows that are triggered simultaneously within a repo too which might work well for you, but if you need them in a particular sequence then you might need to look at repo dispatch again. I’m sure others have solved this riddle other ways too.

I will say that personally I like GA a ton more than Jenkins, but it’s definitely not as full featured. Jenkins has been around for 15 years where GA has only been around for like 2 years so there’s still a lot to be desired but the trade off of managed worker nodes is well worth it to me.

One other word of caution, be careful a bout what GitHub Actions you use from the Marketplace. There’s a fair amount of abandoned projects out there, even sometimes the one with the most stars isn’t the one you really want.

Aumkar Prajapati avatar
Aumkar Prajapati

Hey! Wow, thanks for the detailed reply! I really appreciate it! As for what you said it indeed is somewhat of a puzzle but I really want to move away from our aging Jenkins stuff which is on life support at this point.

For pathing, I already have something set up, where it actually will check for certain kinds of files that match the criteria, i.e all of our java builds have dockerfiles in them, all of our react builds have package.json, so that’s handled. Building and testing criteria is handled by flags in a build.properties file that already exists in each subfolder which we use to determine if it’s buildable, testable and deployable.

My only concern right now is how a repository dispatch would work, would I be able to call it from anywhere inside the job? Similar to how Jenkins pipelines can spin off another job?

Darren Cunningham avatar
Darren Cunningham

disclaimer: I could be wrong about this

You can do that, but it’s async so you can’t do something like:

- step 1
- step 2 
- <repo dispatch>
- step 3 
Aumkar Prajapati avatar
Aumkar Prajapati

Hmm…that makes it a little more complicated as I need to retrieve all the changed files and determine which job goes where. I’ll dig into it.

Aumkar Prajapati avatar
Aumkar Prajapati

Though based on what you sent me before, it looks like a regular step, doesn’t look async to me

Darren Cunningham avatar
Darren Cunningham

it’s just that you can’t trigger a child pipeline and wait for the result before continuing within a single pipeline

Darren Cunningham avatar
Darren Cunningham

that’s all I was trying to represent with that

Aumkar Prajapati avatar
Aumkar Prajapati

Ah, I wouldn’t need that single pipeline to continue, all it needs to do is hand off to the other workflows

Aumkar Prajapati avatar
Aumkar Prajapati

Cause those are the ones that will pass / fail

Aumkar Prajapati avatar
Aumkar Prajapati

I.e master workflow determines all changes, starts handing it off to the pipelines that will build / test / deploy the Java, or react code. Master workflow can then stop.

Darren Cunningham avatar
Darren Cunningham

you should be able to achieve that with GA just fine

Aumkar Prajapati avatar
Aumkar Prajapati

Thanks for your help!

Aumkar Prajapati avatar
Aumkar Prajapati

I thiiink I have a better idea of how to handle this.

Erik Osterman (Cloud Posse) avatar
Erik Osterman (Cloud Posse)

Also, I would check out the composite actions -that can DRY it up a lot

Aumkar Prajapati avatar
Aumkar Prajapati

Composite actions? I’m somewhat of an Actions newbie haha, got any docs / refs for it?

Erik Osterman (Cloud Posse) avatar
Erik Osterman (Cloud Posse)
Creating a composite action - GitHub Docsattachment image

In this guide, you’ll learn how to build a composite action.

2021-10-16

2021-10-18

    keyboard_arrow_up