How to trigger repository_dispatch event for non-default branch? #24657
-
The Github Actions documentation mentions the Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 25 comments 8 replies
-
Hi @phil-opp, Thank you for being here! I wish I had better news for you, the |
Beta Was this translation helpful? Give feedback.
-
Thanks for clarifying! Perhaps the documentation at https://help.github.com/en/actions/automating-your-workflow-with-github-actions/events-that-trigger-workflows#external-events-repository_dispatch should be updated to reflect this (the |
Beta Was this translation helpful? Give feedback.
-
Also, when the documentation links “Webhook Event Payload: repository_dispatch” through to the repositorydispatchevent type on the v3 version of the documentation, it makes it seem like I can use the payload body there, but trying to use branch gives:
Both are a bit confusing, would be good to update if only default branch is possible. |
Beta Was this translation helpful? Give feedback.
-
My problem with the repository dispatch is that it needs a token with repo permission. Isn’t it possible to severely limit the scope of the token in order to avoid consequences if it gets compromised? |
Beta Was this translation helpful? Give feedback.
-
This seems like a different problem, so it’s probably better to create a new topic for it. |
Beta Was this translation helpful? Give feedback.
-
Since we need this a lot… two questions:
Our situation is as follows:
This is a simplified explaination, in reality we now have 4 repos that inter-depend and that number will probably grow. This will make the baby-sitting very time-consuming. |
Beta Was this translation helpful? Give feedback.
-
is there any update on this issue? it makes the repository_dispatch useless if only triggered on master (or default) branch |
Beta Was this translation helpful? Give feedback.
-
@AndreaGriffiths11 Any update on this? This is available in GitLab and allows creating powerful workflows and easy iteration on them (as you don’t have to commit temp workflows to master while developing on feature branch) |
Beta Was this translation helpful? Give feedback.
-
Clarification: which branch a repository dispatch is triggered for 📝
phil-opp:
another-dave:
That’s great feedback. Our team recently updated the documentation to include a
Workaround: specifying a branch using the repository dispatch event 👷♂️
tombrus:
Here’s an example repository that showcases using the repository dispatch event and
GitHub - actions-packages-examples/branch-builds: Example for demonstrating...Example for demonstrating branch builds using the repository dispatch event and actions/checkout@v2. - GitHub - actions-packages-examples/branch-builds: Example for demonstrating branch builds usin... In the workflow file, it’s possible to leverage that input to checkout a specific branch (like what’s defined on these lines of the workflow file). However, the Update: the latest news on the repository dispatch feature 📰
tombrus:
missedone:
👋 Hello! Neither @AndreaGriffiths11 or I are able to speak to upcoming product updates. However, any new ships are either published in the form of a changelog entry or an article in The GitHub Blog. Today, the best place to share requests for new or updated features is through our official product feedback form. Our product team working on Actions monitors that channels and considers each entry, but they may not be able to respond to every submission. |
Beta Was this translation helpful? Give feedback.
-
Thanks for your reply! Unfortunately, the workaround you mentioned has a big drawback: It runs the workflow file specified on the default branch, not the workflow file of the checked out branch. So this only really works if the two branches have the same build/test instructions. Some examples where this doesn’t work:
So this workaround only works in the very specific case where both branches have exactly the same build instructions and use no advanced features such as skipping steps based on the current branch name. To solve this problem for more use case, we need some way to trigger a workflow run on a different branch using the workflow file of that branch. I’ll send a feature request for that through the form you linked and I encourage others to do so too. |
Beta Was this translation helpful? Give feedback.
-
A new |
Beta Was this translation helpful? Give feedback.
-
@nitive - Ah, thanks for mentioning that! Our team also published a changelog entry for this feature that might be worth checking out as well. ✌️ |
Beta Was this translation helpful? Give feedback.
-
Evilweed:
That’s in a simple single sentence exactly why a ci/cd tool would need this capability… Please Github…
francisfuzz:
But this alternative could make it. It would make sense then for Github to display the checkout ref on the Actions tab to give more insight about what happened on our runs. |
Beta Was this translation helpful? Give feedback.
-
Are you sure that this can address the problem discussed here? I have tried this and failed. Here is what I did:
I followed Actions - GitHub Docs and tried
It seems like The @phil-opp has tried hard to clarify the challenge he’d like to overcome:
This is really important for the developer experience around building workflows/actions. I’ve commented on that before, here: How to develop (iterate on, debug!) a workflow file in a non-default branch? - #3 by brightran I don’t want to commit to main/master before having tested the workflow properly. |
Beta Was this translation helpful? Give feedback.
-
@jgehrcke we found a workaround to trigger
We are not happy that we have to make an extra commit every time, but at least we don’t have to commit workflow to default branch |
Beta Was this translation helpful? Give feedback.
-
I am having the same issue but in my case the workflow yaml is on the default branch I can dispatch the workflow if I specify
To be clear this error is different from the error for non existent workflows:
and this error is also different from the error for non-existent branches:
|
Beta Was this translation helpful? Give feedback.
-
I got it working after committing the workflow yaml to both the default branch and the branch you want to run on. |
Beta Was this translation helpful? Give feedback.
-
Whoa, I hope Github developers make this less of a mess.
Say I modify 2, i.e. the workflow files are not synced. Which one gets run? It appear 2 gets run. So I’m thinking 1. could be a LOT simpler. git.luolix.topkaihendry/countComparing serverless platforms. Contribute to kaihendry/count development by creating an account on GitHub. |
Beta Was this translation helpful? Give feedback.
-
Any updates? I just want to get a workaround if the parameters could pass through an overridden value of GITHUB_SHA. marvinpinto/actions/blob/4d6da7f4aa2ff406ad115549df3d9972487ce797/packages/automatic-releases/src/main.ts#L295
|
Beta Was this translation helpful? Give feedback.
-
Any update on this? |
Beta Was this translation helpful? Give feedback.
-
same issue on
|
Beta Was this translation helpful? Give feedback.
-
I think there's some confusion in this thread. In the GitHub Action docs, I thought the feature everyone is looking for is called "repository_dispatch" but in the REST documentation, it's referred to as "workflow_dispatch", which in GitHub Actions is a manually triggered event from the UI. https://docs.github.com/en/rest/actions/workflows#create-a-workflow-dispatch-event https://docs.github.com/en/rest/repos/repos#create-a-repository-dispatch-event In the docs, I can see that both can be triggered via a REST call, and there are slight differences in the request paths and data payloads. Would someone at GitHub be able to clarify the use-cases for both of these in the docs? What are the advantages of one over the other? The title of the post is about repository_dispatch, but people are also asking about and suggesting workflow_dispatch, which might be leading to some confusion. Thank you! |
Beta Was this translation helpful? Give feedback.
-
Any update on this? or any workaround? |
Beta Was this translation helpful? Give feedback.
-
Hi All,
|
Beta Was this translation helpful? Give feedback.
-
Just got so annoyed that this doesn't work out of the box for pull requests, that I just had to build it myself: https://github.com/marketplace/actions/rebuild-stale-pullrequests |
Beta Was this translation helpful? Give feedback.
A new
workflow_dispatch
event can be used to trigger workflow for non-default branch.https://docs.github.com/en/actions/reference/events-that-trigger-workflows#workflow_dispatch