✨ Question of the day ✨: Do you have any use case for Reusable Workflows? 🆘 NEED HELP? 🆘 Book a 1:1 Consultation with CoderDave: geni.us/cdconsult We can talk about GitHub, Azure DevOps, or any other DevOps tool or project you need help with! 🙏🏻SUPPORT THE CHANNEL🙏🏻 Buy me a coffee: www.buymeacoffee.com/CoderDave PayPal me donation: paypal.me/dabenveg
@RajabNatshah3 жыл бұрын
Yes .. Having a workflow for products ( or project templates ).. then in each project could reuse the workflow .. not have a copy of the product workflow.. only reuse
@a2zbabysteps Жыл бұрын
@CoderDave Can we call the reusable workflow via curl - asynchronously (like fire and forget calls to these steps). i.e. our progress of main workflow should not be waiting for output from this reusable workflow?
@CoderDave Жыл бұрын
No, unfortunately that is not possible. I can see the usefulness of that tho
@LukeSteel-n9n Жыл бұрын
Excellent Tutorial! If the reusable workflow is in a different repository, is it possible, in the caller workflow and under the job calling the reusable workflow, to checkout that second repository holding the reusable workflow? Also it seems performing the checkout (of the second repo) within the reusable workflow itself, never take effect; rather the checked-out caller workflow repo persists all through the entire job run.
@CoderDave Жыл бұрын
Thanks :) No it is not possible, not directly anyway. If you use the checkout step in the reusable workflow, it will always checkout the caller repo. If you want to checkout the repo where the reusable workflow is (let's call it "myuser/reusables") then you can use the `repository` parameter of the checkout action (under `with`) and hardcode the "myuser/reusables" repo name there
@AleksandarIvanov693 жыл бұрын
Seeing how we are both looking at the same things, but you being way down the path we are on and the fact that everything I've seen from you so far has been great, I would love to see the following videos on your channel: - Tutorial: How to run a GiHA workflow inside a container with non-root context - Recurring series: Reviewing GiHA Ci/CD pipelines
@CoderDave3 жыл бұрын
First of all, thanks for the compliments :) Second, for Actions in container it is a little tricky, because Actions in Docker won't support running other Docker Actions (and there are a lot)... I'm waiting for the team to support that natively, I don't want to endorse "sketchy workarounds" :) For the last point, what do you mean by "Reviewing Actions CI?CD Pipelines"? You mean the workflows I have, or some viewer workflow, or...? I think this could be interesting, thanks for the suggestion! PS: if you want, join our Discord server: geni.us/cddiscord
@AleksandarIvanov693 жыл бұрын
@@CoderDave I mean reviewing other people's pipelines, to point out mistakes, what could be improved and how. Something like that :)
@CoderDave3 жыл бұрын
Sounds like a great idea!
@AleksandarIvanov693 жыл бұрын
@@CoderDave I have a submission at hand already, so whenever you are :)
@CoderDave3 жыл бұрын
Let's see if we get enough interest on this, but I love the idea. Thanks! Check this out and submit your application ;) kzbin.infoUgkxJ0P46PUBTAXcuh8VmbvTBJaNQsjckn0W
@AleksandarIvanov693 жыл бұрын
It's good to have both CAs and RWs as an option, cause even tho they largely overlap, each one fits very specific different use cases. We are fiddling internally with both right now and we are fascinated by the potential for elegant solutions they both provide :)
@CoderDave3 жыл бұрын
I agree, there is an overlap and you can do similar things with both. But I think the “philosophy“ behind them is different.
@adamsebetich92903 жыл бұрын
Huge! Finally this comes out. I’ll wait for it to not be in beta to use
@CoderDave3 жыл бұрын
True, we were waiting for this for a while. I think you can start using it already, it seems pretty stable. I believe (but this is just my idea) that if anything will change from beta to GA will be added features, not removing anything 😄
@kumarsaroj182 жыл бұрын
loved this video.. crisp, but still very informative. I was looking for a way to optimize and reduce the number of similar workflow files.
@CoderDave2 жыл бұрын
Thanks 🙏🏻 always happy to know I’m helping ☺️
@iceboxbob2 жыл бұрын
Do you think I can run specific jobs from the called workflow in a caller workflow?
@CoderDave2 жыл бұрын
Yes, but you’d need to implement the logic by yourself. For example, having some IF conditions in the template and then passing the variable from the caller to the reusable workflow to control the execution
@iceboxbob2 жыл бұрын
@@CoderDave cool, thanks for the response. Your video was helpful.
@lucsegers6931 Жыл бұрын
really loved this video, thank you. Did the reusable workflows changed a lot since this video? I understand the use of composite actions and reusable workflows, but what about templates? How does templates compare to reusable workflows and composite actions. Is templates being deprecated?
@CoderDave Жыл бұрын
Thanks for the comment! AFAIK, Actions has never had templates (like for example Azure Pipelines has). Reusable workflows are the "de facto" templates in GitHub Actions. Them, and Composite Actions. Both can be considered sort-of templates. You may wanna check my video about that: kzbin.info/www/bejne/sJSUaqCIaLRnl5Y
@ShyamKumar-yn2jw3 жыл бұрын
how to call a workflow in a private repo. it says it private reusable workflow can be used only in the same repo. but didnt worked for me. Thanks in advance.
@CoderDave3 жыл бұрын
You can call them in private repo from the same repo, using the "normal" syntax: jobs: your-job-name: uses: username-or-org/repository-name/.github/workflows/worflows_file-name.yml@your-version-tag-or-branch
@ShyamKumar-yn2jw3 жыл бұрын
@@CoderDave Thanks :) , it worked, I missed the branch/tag
@suhaskulkarni58572 жыл бұрын
How can we use org secrets in the workflow call? The workflow call always accepts secrets from called workflow by using inherit. Is there a workaround to use the secrets from workflow call repo or org secrets?
@CoderDave2 жыл бұрын
Hi, afaik there is no way to be consume a secret directly from the reusable workflow. All has to be passed from the caller using the secret parameters
@NunoMaiaNM2 жыл бұрын
I've setup two workflows in the same repository, and the called workflow does not receive any inputs passed from the caller :( . Do you have any sugestion?
@CoderDave2 жыл бұрын
Uhm that’s very hard to understand without seeing the workflows… perhaps you can join our discord server and ask there so we can take a look at it ☺️
@sahilchaudhry082 жыл бұрын
Are the reusable workflow similar to templates in Azure DevOps YAML pipelines?
@CoderDave2 жыл бұрын
They are somewhat similar, they can be used more or less for the same scanarios
@sahilchaudhry082 жыл бұрын
@@CoderDave I have already built some Azure devops YAML templates to build and deploy dotnet applications so I want to build similar stuff for Github Actions. What do you suggest?
@CoderDave2 жыл бұрын
Yes, that is definitely a good use case. I'd create a repo with all the reusable workflows and you're good to go :)
@vishnuvardhan-dg6xm2 жыл бұрын
Hi Dave, I have two repos consisting projects in one and dependecy poms in another. Selfhosted runner is being used. To build the services i need to install the dependencies in maven local repo and resolve them while building. How could i build the dependencies to maven local repo prior to building services in another repo using reusable workflows.?
@vishnuvardhan-dg6xm2 жыл бұрын
I have multiple workflow files for different services in one repo configured for same event. How can i stop all the workflows getting triggered except the service wish to run if committed?
@CoderDave2 жыл бұрын
It is difficult to answer this without knowing how your repo is structured. I'd go with one of those 2 solutions. If your different services are in different folders, you can add the branch filter to your triggers... something like: on: push: branches: - main paths: - service1/ more docs here: docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-including-paths if instead they are not in different folders, you could use the job conditionals to check for specific conditions (like file names, comments in the commit, etc)
@vishnuvardhan-dg6xm2 жыл бұрын
@@CoderDave Thank you Dave 😀
@moustafa60062 жыл бұрын
now you can reference a reusable workflow just like composite action. Meaning, it will use the file in the same branch with a path instead of using the repot and a ref.
@CoderDave2 жыл бұрын
Yes, you can host them in either another repo or in the same repo, it is neat :) I talked about this in last week's video :)
@KennethRrvik3 жыл бұрын
Great little snippet, helped me getting a quick test in action ;)
@CoderDave3 жыл бұрын
Great to hear!
@MichaelRainabbaRichardson2 жыл бұрын
Is there a plan to see the environment variables translated into the shared workflow? Is there a reason that isn't currently done? Outstanding video and exactly what I needed. Thank you.
@CoderDave2 жыл бұрын
Thanks! unfortunately I don't have an answer on your questions... I;m sure there is a technical reason why the env variables are not expanded to the reusable workflow, but I'm not sure why...
@gagikmirzoyan98842 жыл бұрын
I"m not sure if there was this method during the time this comment posted, but alongside parameters of reusable workflow under "with:" you can have "secrets: inherit" so reusable workflow will inherit caller workflow secrets.
@fromhereandthere460 Жыл бұрын
@@CoderDave then if you have a repo that needs an environment variable exclusive to it, then you can't use the reusable workflow because it won't be referenced in the re-usable-workflow right?
@fellifel1472 жыл бұрын
Do u have any videos on workflow_run?
@AnilKumar-qh5gz2 жыл бұрын
I was able to create a reusable workflow (reusable.yml) and a caller workflow (caller-reusable.yml), which works fine. Thank you for the great video. Now my requirement is to pass a JSON file/data from caller workflow to the reusable workflow for some processing. I tried passing the JSON file/data from caller workflow to reusable workflow and then process the JSON file in reusable workflow by calling a PS script. But I am not able to refer to my PS script file (test.ps1) which has been created in reusable workflow. It simply throws below error, thought the path is correct: The term '/test.ps1' is not recognized as a | name of a cmdlet, function, script file, or executable | program. Check the spelling of the name, or if a path was | included, verify that the path is correct and try again. Any pointers please?
@CoderDave2 жыл бұрын
When a reusable workflow is executed, the “context” is set to the caller workflow… this is why you cannot find your file. You could create a Composite action for the step where you need the ps file (in that case it is used), and reference that in the reusable workflow
@kalirajaramasamy12483 жыл бұрын
Thanks for awesome video. I tried this approach and getting the below error. No steps defined in `steps` for the following jobs: docker. I tried in enterprise github account. Could you please help me on this error?
@CoderDave3 жыл бұрын
It looks like GitHub doesn’t recognize your reusable workflow. It’s difficult to say without seeing your setup, but I’d double check the syntax in both files and see if everything is correct… with YAML just a small thing missing and everything stops working 😁
@kalirajaramasamy12483 жыл бұрын
@@CoderDave I just followed your videos and double cheked the indentation as well. Everything looks correct. One thing to note here is, In our project github account composite action also does not work. Composite action is not yet available for enterprise github account.
@CoderDave3 жыл бұрын
Uhm that is very strange. Both composite actions and reusable workflows are available in GitHub Enterprise. I’ve use them in GHEC already with clients. But it doesn’t work if they are hosted on private repos. They must be in public repos or internal repos with the proper settings
@yankee-in-london2 жыл бұрын
Great video but being a bit of a newbie I am struggling to get this to work where the Parent and Child workflows are in the same repo. I figured the parent workflow could run a conditional statement and then reference the other workflow with "./.github/workflows/my-workflow" but it says it can't find it and I've been in a spin cycle since.
I think part of my confusion is how to separate Actions and Workflows ... your example seemed to point to actions/my-workflow but you defined a workflow.
@CoderDave2 жыл бұрын
On the phone right now so I can’t test, but I believe for local workflows you need to use the full path, including “.yaml” extension
@yankee-in-london2 жыл бұрын
@@CoderDave I eventually got it to work ... you not only need the '.yaml' but you also seem to need to self-reference the repo name and branch ... a bit awkward but it works
@RajabNatshah3 жыл бұрын
Thank you :)
@CoderDave3 жыл бұрын
Welcome 😀
@akankshayadav75752 жыл бұрын
What is the difference between composite action and reusable workflows
@CoderDave2 жыл бұрын
Great question, there are many differences, in fact too many for just an answer to the comment. But you can see composite actions as a subset of feature of reusable workflows. In general, composite actions are simpler, cannot use conditionals or multiple jobs, and have limited logs. Reusable workflows, on the other hand, are much more feature-rich, and can be seen as actual templates. I will make a video about the comparison soon, stay tuned.
@akankshayadav75752 жыл бұрын
@@CoderDave Thank you so much
@akankshayadav75752 жыл бұрын
Is shared libraries concept of GitHub Actions = reusable workflows ?
@CoderDave2 жыл бұрын
More or less, yes
@koodauskanava90963 жыл бұрын
Thanks for this, very nice introduction video
@CoderDave3 жыл бұрын
Glad you liked it!
@Only_Good_Trip Жыл бұрын
Really helpful :-) thanks a lot
@CoderDave Жыл бұрын
Glad you found it helpful ☺️
@subhajitsarkar75152 жыл бұрын
this was really helpful , t hanks
@CoderDave2 жыл бұрын
Glad it was helpful!
@iimnurdiansyah532 жыл бұрын
Nice info, thanks
@CoderDave2 жыл бұрын
More than welcome ☺️
@ashu9103 Жыл бұрын
when I call reusable workflow, it does not checkout reusable workflow repo but it checks out calling workflow. your example is not helpful.
@CoderDave10 ай бұрын
That is how it’s designed to work… if you don’t like it , talk to GitHub… nothing I can do about it
@dannyv12 Жыл бұрын
So why do you have to rebuild your app for every job this is pretty lame. 😢
@CoderDave Жыл бұрын
You don't have to... that was just an example... you can make the job(s) and workflow(s) do whatever you need them to
@dannyv12 Жыл бұрын
@@CoderDave so how can i reuse a job build and use that in the new run-as for the new job because I can't find it?
@CoderDave Жыл бұрын
You mean building your app on Job A and reusing the build artifact on job B? That is not what reusable templates are for. To do that you can use the “upload artifact” action in job A and the “download artifact” action on job B