On: workflow_run: does not work with release created #26548
-
Hi, I’m having some problems with GitHub Actions and I really can’t find any useful documentation about that. To summarize: CI
CD
Can someone tell me why ? Am I wrong or is this a bug ? |
Beta Was this translation helpful? Give feedback.
Replies: 16 comments
-
Do you have both workflow files in the same repo? |
Beta Was this translation helpful? Give feedback.
-
Yes for sure, this is the project CI runs, CD no |
Beta Was this translation helpful? Give feedback.
-
huh. First glance it looks right, but we are missing something, logic or otherwise. I’ll take a look at it later today when I get a chance in more detail, and see if I can recreate it. Question: What about your other triggers in the CI? For example, if you do a PR to master, not create a release, does that trigger the CD? Or does the CD still not run? |
Beta Was this translation helpful? Give feedback.
-
Thank you! |
Beta Was this translation helpful? Give feedback.
-
interesting, so it only occurs when the Release creation triggers the CI. Good to know. |
Beta Was this translation helpful? Give feedback.
-
Exactly, is seems so. Once I create the Release CI works but once completed CD is not triggered |
Beta Was this translation helpful? Give feedback.
-
Another question: RIght now you have two workflow files CI and CD. Have you considered just doing it all in one workflow file instead? Any reason you don’t want to do that? |
Beta Was this translation helpful? Give feedback.
-
Just to keep them clean and separated, no other reasons honestly. Do you think this can be problematic? |
Beta Was this translation helpful? Give feedback.
-
Not necessarily problematic. But in general right now, putting things in one file can be a little simpler. You can still keep it clean by using multiple jobs. |
Beta Was this translation helpful? Give feedback.
-
Ok thanks for the advice! |
Beta Was this translation helpful? Give feedback.
-
That said I still want to figure out why this scenario isn’t working. Still looking into it. |
Beta Was this translation helpful? Give feedback.
-
Any news? Did you replicate it? |
Beta Was this translation helpful? Give feedback.
-
OK, I was able to recreate it, and I know why it is happening. This repo is where I was working on it: GitHub - mickeygoussetorg/deleteme The problem is in your CD triggers, and in what is in the GitHub context object when you trigger off a created release vs when you just do a push. If you just do a push, then the “ref” in the GitHub context object is refs/heads/main (or master, depending on what you use for your default branch). You can see that here. However, when you trigger off a release, the ref is instead: refs/tags/releasetag. You can see that here. Therefor, when the CD does its check, one thing you have it checking for is branch: master. Well, the CI wasn’t triggered from branch master it was triggered from refs/tags/releasetag, so you logic equates to false and it doesn’t run. You can test this yourself by commenting out branch: master in your CD, and you’ll see that once you create a release, the CI runs, and then the CD runs. Its a logic issue. You need to rethink your logic. |
Beta Was this translation helpful? Give feedback.
-
Great! Thank you! UPDATE: geirolz/advxmlA lightweight, simple and functional library DSL to work with XML in Scala with Cats |
Beta Was this translation helpful? Give feedback.
-
This line isn’t going to work, because you didn’t call your release “releasetag”. You called it v2.3.1. So the logic is going to evaluate to false, because the tag didn’t match. I’m out of office for the next few days, but I’ll see if I can wrap my head around a way to figure out the logic on this. |
Beta Was this translation helpful? Give feedback.
-
I think we can close this ticket, I’ve resolved removing this check, it’s not mandatory actually. Thank you so much @mickeygousset for your help! |
Beta Was this translation helpful? Give feedback.
OK, I was able to recreate it, and I know why it is happening.
This repo is where I was working on it: GitHub - mickeygoussetorg/deleteme
The problem is in your CD triggers, and in what is in the GitHub context object when you trigger off a created release vs when you just do a push.
If you just do a push, then the “ref” in the GitHub context object is refs/heads/main (or master, depending on what you use for your default branch). You can see that here.
However, when you trigger off a release, the ref is instead: refs/tags/releasetag. You can see that here.
Therefor, when the CD does its check, one thing you have it checking for is branch: master. Well, the CI wasn’t triggered from branch…