[Music] hello everyone welcome to let's
devops myself sumit and today we are going to discuss about how to trigger github
actions workflow from another workflow and for all the demo and description
i will be following this article and the link of this article is
available in the video description now let's start so first is the introduction so
from the title itself you are aware that we are going to talk about how to trigger workflow from
another workflow and this will help in multiple use cases when you are required to trigger other
workflow on same or a different repository okay talking about the architecture basically
we will have one or more workflow where one workflow can be triggered from the
another workflow and this can be achieved through the repository dispatch as well as a python script
talking about the use case so basically this method we can use in a multiple use cases uh one
example if i can say assume that i want to trigger workflow 2 whenever the workflow one fails right
so that is the one use case you can assume second is like maybe you have a multiple workflow
and you want it to have a dependency like you wanted to make sure the workflow to complete
before workflow one right so that that kind of use case or technique you can use with the help
of this particular demo and the description okay so talking about the method of trigger so
we already discussed today like we can use repository dispatch right uh which
will help to trigger the workflow but we can also uh add some more
limitation or maybe you can say that assume that you have a five workflow right and all
of them has a repository display so when whenever the workflow one will understand which repository
dispatch it needs to pick up so for that basically we need to add event type so here if you see
we are adding the event type as a workflow too so whenever there is a payload request with the
type of workflow 2 then only this particular workflow will get triggered so we will discuss
that more in the demo also i will show some of the basic example so that you can understand
more on it talking about the setup so as part of this process uh we will set up to workflow
workflow one and workflow two in the workflow one basically we use to trigger the workflow tool
right so we'll have some setup on the workflow one which helps to trigger the workflow too so
here if you see here we have mentioned the workflow one is a triggering workflow and the
workflow two will be the trigger workflow okay now let's see the workflow one setup so here is
i have one sample workflow which i have created uh it is a publicly available so you can just
click on it and it will open this particular page so let's try to review this workflow and how
basically this is the workflow one if i mention how we have made a configuration of
workflow 2 so that it will trigger trigger that workflow of the workflow tool
right so first of all if you see uh yeah this is the name of the workflow one right and
uh we are passing some of the information because we need to trigger workflow two right so
what is the name of the workflow so in our case uh it is a workflow tool what is the account
uh where this particular workflow exists and third what is the repository right so that is
also very important because the workflow can be on a same repository or it can be on a different
repository as well so one more important uh part is that uh the pad token right so that also you
need to configure in the sense of this is like the pack token of the workflow tool right so that
configuration you need to make in the workflow one so here if you see and if you see we are
basically using a python script this python script can be found in this particular repository
itself like under the deployment script we have workflow trigger and whenever we are calling this
particular or python script we are passing some information of workflow 2 okay so let's go here
and see the deployment right so here we have uh the trigger the python script so it's it's
doing nothing it's just kind of picking the information like a token owner name repo name
uh and there are some payload uh which you are we we have configured here like uh this is
just for information like if you want to send some information from one workflow to another
like workflow one i want to pass the baseline number i want to pass the baseline revision
number if those thing i wanted to pass i can send that as a payload right so we are basically
here we are making a rest api call where we are passing um the workflow name and uh the
baseline number and the division number so one thing here if you noticed we are uh
providing the event type as a workflow name so it means that wherever there is a repository
dispatch with the event type workflow name in our case we are passing workflow to right that uh
workflow will get triggered with this particular rest api call okay so let's go back to the tower
article now and talk about the configuration so here if you see uh yeah in this workflow one
we need to provide this particular detail of workflow 2 like what is the workflow to name what
is the github account repo what is the pack token and then the payload details so right now i am
passing only two maybe as per your requirement if you want to pass some more details you
can pass through the payload right so payload basically is the data which can
be sent through the rest api call and this is the trigger the workflow ticker
python script and that is available in this location this location is also publicly
available so you can have a look to it talking about this uh yeah this is the workflow
the workflow one example which i have added so these are the some of the sample which
i have given for my own github account right so this is the workflow tool which is
already created just for the demo purpose so you can just have a look to it and here
you can see we are passing two uh two payload details one is the baseline number and another
is the baseline revision as per your requirement you may pass multiple payload uh detail or data
so assume that i have a workflow too and i want to pass some some information before i trigger the
workflow right like assume that i wanted to uh gives a parameterized value to that particular
ah workflow then you can pass as a payload okay and these are some the method
which we are using it so basically as part of this uh this workflow we are
calling this particular python script and we are passing some information which is
relevant or to trigger that workflow too okay now let's talk about the workflow setup so
as part of the workflow one we understood okay what are the setup we need to do for workflow 2
setup also i have created a sample we can quickly review that as well so this link is available
publicly so you can have a look so here if you see one important uh configuration that we made
it is uh the repository dispatch right with that with the help of this only it will it will accept
that particular call to trigger that particular workflow so here we are giving the type as
a workflow tool right so this particular event will get triggered whenever there is a rest
api call from the workflow 1 and the type of that repository dispatch is workflow too talking about
the payload right so we also discussed about through the workflow one we are passing some
payload data right and here you can read those data from this particular command like github
event dot client payload and baseline tag and baseline number or division number so that's all
right and then here if you see i have given some sample information just a psycho
okay so let's go back to that our article so coming back here under the
configuration if you see yeah definitely the repository dispatch you need to make sure you
you have to add it in the the workflow to which you are going to trigger from the workflow online
and some of the payload value so as i mentioned before you may add some more payload data also
just for example i have given some baseline tag and visa number okay and again this workflow is
already available here so you can have a look and just it is for a demo purpose i have
configured and here if you see um like as part of this particular step or the task i'm
trying to read basically i am trying to print those baseline tag and baseline revision number
which i have received from the workflow one ok now talking about the the workflow right
how we can basically trigger the workflow so that uh the other workflow can be
triggered so as for the example since we i have created two workflow workflow one and
workflow two and workflow whenever you trigger workflow one it will automatically trigger
the workflow tool right so we will see that particular so for that uh basically you need to
click on this url this this uh this is a public uh repository you can have a look to it
and if i if you go to the action right here there are two workflow which i have created
so now for a testing purpose since that all the configuration we already have made we'll try to
uh trigger this workflow one and see whether it is automatically trigger triggering workflow two or
not okay so i'll just click on run workflow right and just fill it uh wait for a few seconds meanwhile we can also come here so i think
that's all we have information so here i have given some detail like how basically you can
trigger the workflow okay so workflow one is running currently you can come here and also
see the details so i think it's almost completed right so now let's see whether the second
workflow is got together so now you see the workflow t's got uh workflow to got
automatically triggered and it also succeeded so now if you try and come and see what are
the value we have so if you see here uh these are the value also it is getting getting
printed right and this value we have passed through the workflow one okay
so that's all from the demo so that's all for this particular demo uh
thanks for watching and if you have any issue while setting up this particular configuration
you can write in your in the comment section i will be responding to that and the last
thing is like yeah if you like this video kindly share it uh subscribe it and don't forget
to like the video as well so thanks for watching [Music] you