Trigger Github Action From another repo using `Trigger Workflow and Wait` Api

Husnain Siddique
3 min readJul 2, 2023

--

In this article, I am discussing how to trigger a workflow that‘s in another repo on a certain event using the `Trigger Workflow and Wait` Api.
Let say you have one repo named parent_repo and another is named child_repo and you want to trigger the workflow that is in the child_repo when some event (let's say pull request is merged into main) occurs in the parent_repo.
First, you need to create a folder named `.gihub/workflows` in both repos then you need to create a workflow in both repositories.

Setup a workflow in the parent_repo that triggered when the main got updated

Also setup a similar workflow in the child repo

Now we have to set up `Trigger Workflow and Wait` Api to trigger the child_repo workflow when the parent_repo main branch got updated

owner: (The repository owner)
repo: (Repo name of which workflow you need to use)
github_token: (You need to add a personal access token to access this repository in the GitHub runner)
workflow_file_name: (Name of the workflow file)
ref: (Branch reference where the workflow is present)
wait_interval: (check for workflow if it's finished to report the workflow status)
propagate_failure: (Fail the parent workflow if the triggered workflow fails)
trigger_workflow: (To trigger workflow)
wait_workflow: (Wait for the workflow to finish)

Now if the parent_repo main branch got updated the workflow is triggered and after setting up the API it will trigger the child_repo workflow.

In the parent_repo
In the child_repo

You can read further from the API documentation https://github.com/convictional/trigger-workflow-and-wait
If you want to use the above code you can get that from here
https://github.com/husnain581
If you have any questions you can email me at
husnainsiddique581@gmail.com

--

--