-
I remember seeing somewhere that you could trigger a different workflow from another workflow? For example, if Workflow A is successful would it trigger Workflow B to send a notification about the success. Is this still possible, or did something change? |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments 5 replies
-
Yep, you can c****reate a repository dispatch event to trigger a workflow from another workflow. For example, there 2 workflows ( wf1 and wf2 ), they can be in a same repository or different repositories. At the end of wf1, you can add an additional job to create a repository dispatch event via executing the GitHub REST API for the repository that cotains the wf2. And in wf2, you should set its trigger event as on: repository_dispatch A simple example: NOTE: you need to create a new PAT instead of the automatically created GITHUB_TOKEN to authenticate the API. This new PAT should have permissions to access the repository that cotains wf2, and you aslo need to add this new PAT as a secret in the repository that cotains wf1. |
Beta Was this translation helpful? Give feedback.
-
This action might help you if you want to use an |
Beta Was this translation helpful? Give feedback.
-
So I could also use this across repositories? That’s handy, as I would like to automatically update specific files in a repository when I update them on another. I asked about this here but didn’t get an answer yet. So if you have an idea of how I could achieve this, let me know. |
Beta Was this translation helpful? Give feedback.
-
Can this be achieved by using GITHUB_TOKEN yet? I have security requirements to no longer use PATs. |
Beta Was this translation helpful? Give feedback.
-
Same requirement on my end. can this be done with the GITHUB_TOKEN instead of a PAT? or perhaps some other mechanism which has a limited security concern Vs the PAT ? |
Beta Was this translation helpful? Give feedback.
-
We have the same drive to move away from PAT tokens as they are difficult to scope well and are tied to a single user (not to mention using up a paid user seat in your org) You can do this with a GH App by using this action to generate a token and then using it in subsequent steps GitHub - philips-software/app-token-action: GitHub action to obatin app token You need to make sure you grant the app the correct permissions on your repo (or in your org) and this works well with org level apps. |
Beta Was this translation helpful? Give feedback.
-
It is now possible to do this with GITHUB_TOKEN - https://github.blog/changelog/2022-09-08-github-actions-use-github_token-with-workflow_dispatch-and-repository_dispatch/ |
Beta Was this translation helpful? Give feedback.
Yep, you can c****reate a repository dispatch event to trigger a workflow from another workflow.
For example, there 2 workflows ( wf1 and wf2 ), they can be in a same repository or different repositories. At the end of wf1, you can add an additional job to create a repository dispatch event via executing the GitHub REST API for the repository that cotains the wf2. And in wf2, you should set its trigger event as on: repository_dispatch
A simple example:
NOTE: you need to create a new PAT instead of the automatically created GITHUB_TOKEN to authenticate the API. This new PAT should have permissions to access the repository that cotains wf2, and you aslo need to…