-
Hi, I’d like to test a workflow in a PR, but from what I understand it only shows and runs if committed to the “main branch”. Is there a way to have new workflows show and run in the PR stage? Just to be clear, a new workflow in Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 21 comments 17 replies
-
You can trigger off of a pull request event in your workflow file: https://docs.github.com/en/actions/reference/events-that-trigger-workflows#pull_request |
Beta Was this translation helpful? Give feedback.
-
Thanks for looking! But I should have worded it differently. I’m looking to have the workflow peer-reviewed before integrating it into the main branch. This means that the workflow is not yet available or merged with the main branch. Because it is not yet available, displayed, showing in the Github actions, I won’t be able to trigger it: manually, by PR, etc. I believe that Github does not yet support running workflows that only exist in a none main branch. Am I correct? Example use-case:
|
Beta Was this translation helpful? Give feedback.
-
heldrida:
It depends on the event type. There are certain event types for which the workflow file must be on the default branch (e.g. Check |
Beta Was this translation helpful? Give feedback.
-
Thanks for the support! If the PR holding a new workflow hasn’t yet been approved and merged to the “main” branch, is it expected to show in the actions? Here’s an example, which is not showing (the workflow yaml only exists in the pending PR):
My expectation was that at least I could trigger it manually, as you see the |
Beta Was this translation helpful? Give feedback.
-
My apologies, just found that I have the paths, in which the changes at the moment do not full-fill as I’m only working in workflow. By removing it, the action does show as expected! |
Beta Was this translation helpful? Give feedback.
-
for workflow_dispatch, you HAVE to have a version of the file in the main branch. |
Beta Was this translation helpful? Give feedback.
-
But workflow_dispatch will only run the workflow version that’s checked into the main branch, right? |
Beta Was this translation helpful? Give feedback.
-
Ahhh, see that is where things get interesting. To initially make it show up on the Actions tab, and so that you can trigger it manually, it has to be checked in to the main branch. BUT, when you trigger it, you can pick which branch to run it against. The only caveat is that the workflow file (or a version of it) also has to exist IN THAT BRANCH. |
Beta Was this translation helpful? Give feedback.
-
ok, got it. thanks. but for |
Beta Was this translation helpful? Give feedback.
-
That I don’t know I’d have to test it and see. The docs don’t say. Logically it makes sense that yes it would have to be on the main branch for repository_dispatch to work |
Beta Was this translation helpful? Give feedback.
-
As far as I can tell with my limited experience with |
Beta Was this translation helpful? Give feedback.
-
This is what I’d love:
|
Beta Was this translation helpful? Give feedback.
-
I was struggling with this too. I followed what I picked up from this thread and did the following:
|
Beta Was this translation helpful? Give feedback.
-
Fwiw, as long as the repository is public, you can create a public fork and set your public fork’s default branch to the version which has the code you want to demonstrate. (And possibly w/ the same name as the expected destination branch, instead of the name of the feature branch in your fork as used for your PR.) In your case, removing the In some cases you could just add a second branch, as in:
|
Beta Was this translation helpful? Give feedback.
-
Seems like you either need to have it first in Still, I would love if GitHub add the option to be able to display the |
Beta Was this translation helpful? Give feedback.
-
I’m still unsure about how to test a newly implemented workflow before integrating it into the default branch. 🤔 Is there an approach to experimenting with a new workflow and verifying different commands/images, etc., without needing to merge every modification into the master beforehand for testing?” |
Beta Was this translation helpful? Give feedback.
-
Most workflows can be tested on your computer with act. I still would like to see this implemented for edge cases. |
Beta Was this translation helpful? Give feedback.
-
I would like to be able to test workflows with a |
Beta Was this translation helpful? Give feedback.
-
How can such a simple thing be SO SCREWED up on Github?? I simply cannot understand how completely messed up GH actions are. It is absolutely NORMAL for any developer to NOT push things directly on main, I do not want to mess up my main branch only to develop a new action. Unbelievable. |
Beta Was this translation helpful? Give feedback.
-
As stated, I am talking about a workflow_dispatch Action, not triggered by
a push, as I need input parameters.
Finding out why my workflow shows up but cannot be run was a total mess.
When you push a malformed workflow to any branch, no matter the trigger, it
shows up on the left side, but you don't find the "run action" drop-down
anywhere.
It is simply not understandable to a new user and no document explains this.
The only way to develop a brand new action with inputs is to first merge
some empty / incomplete workflow on main in order to then start developing
it on a feature branch. All the time the not-yet-ready workflow is now
shown to all users of the repo as if it were already there and working...
Josh Soref ***@***.***> schrieb am Di., 5. März 2024, 13:25:
… I can't quite tell from your complaint which part of things is bothering
you.
GitHub might not show you a workflow in its left sidebar, but you
absolutely can push a workflow to a branch that is defined to run on the
branch to which you push it, and have it run.
Do you have a specific repository and workflow in mind?
—
Reply to this email directly, view it on GitHub
<#25746 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABETSZTXNRMJ7W6FYR6T7VDYWW2U3AVCNFSM6AAAAAAWBTL4RKVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM4DMNZZGYZDO>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Actually there is way to test a new workflow on branch. First you create a skeleton implementation in the branch that is triggered by on:
push: and push it to the github so the workflow is run and github is aware of such workflow. gh workflow run <workflow-file-name>.yaml -r <branch-name> -f input-field=value |
Beta Was this translation helpful? Give feedback.
My apologies, just found that I have the paths, in which the changes at the moment do not full-fill as I’m only working in workflow.
By removing it, the action does show as expected!