Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mention that workflow needs to exist on default branch to use workflow_dispatch #31007

Closed
1 task done
jsoref opened this issue Jan 9, 2024 · 9 comments · Fixed by #31481
Closed
1 task done

Mention that workflow needs to exist on default branch to use workflow_dispatch #31007

jsoref opened this issue Jan 9, 2024 · 9 comments · Fixed by #31481
Labels
actions This issue or pull request should be reviewed by the docs actions team content This issue or pull request belongs to the Docs Content team help wanted Anyone is welcome to open a pull request to fix this issue waiting for review Issue/PR is waiting for a writer's review

Comments

@jsoref
Copy link
Contributor

jsoref commented Jan 9, 2024

Code of Conduct

What article on docs.github.com is affected?

https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#onworkflow_dispatch

What part(s) of the article would you like to see updated?

Add more text explaining requirements relating to presence on default branch

Additional information

https://github.com/orgs/community/discussions/25746#discussioncomment-8067852

Content design plan:

Add a sentence to the on.worklfow_dispatch section of Workflow Syntax for GitHub Actions that says something like:

This trigger only receives events when the workflow file is on the default branch.
@jsoref jsoref added the content This issue or pull request belongs to the Docs Content team label Jan 9, 2024
@github-actions github-actions bot added the triage Do not begin working on this issue until triaged by the team label Jan 9, 2024
@jsoref
Copy link
Contributor Author

jsoref commented Jan 9, 2024

Some prose should probably also be added near https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#onevent_nametypes explaining which events are handled by the workflow in the default branch and which are handled by other versions of the workflow (which I believe is basically push, pull_request*, and workflow_dispatch if someone with write(?) permissions asks a workflow present on the default branch to run from a non-default branch).

@nguyenalex836 nguyenalex836 added actions This issue or pull request should be reviewed by the docs actions team waiting for review Issue/PR is waiting for a writer's review and removed triage Do not begin working on this issue until triaged by the team labels Jan 9, 2024
@nguyenalex836
Copy link
Contributor

@jsoref Thanks for opening this issue, and providing the discussion this stemmed from 💛 I'll get this triaged for review ✨

@nguyenalex836
Copy link
Contributor

@jsoref Thanks again for raising this flag on this! ✨ We've discussed with the team, and would appreciate if you could send over some snippets for what you hand in mind regarding -

Add more text explaining requirements relating to presence on default branch

Some prose should probably also be added near https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#onevent_nametypes

CC @SiaraMist @jc-clark

@jsoref
Copy link
Contributor Author

jsoref commented Jan 24, 2024

Here's a sample workflow with some runs: https://github.com/jsoref/on.event-name.types/actions/workflows/issue-labeled.yml

I'm not sure how many types this applies to, but at least for on.issue.types, only workflows on the default branch at the time the event is dispatched are consulted.

-Some events have activity types that give you more control over when your workflow should run.
+Some events have activity types that give you more control over when your workflow should run.
+Generally these events are only dispatched to workflows on the default branch.

The reason for this text is that there is a workflow jsoref/on.event-name.types@3bbb2e6 which is on the main branch, and it did not run when the invalid label was added to jsoref/on.event-name.types#3 -- because at the time of that event, the default branch was test not main.

@nguyenalex836
Copy link
Contributor

@jsoref Thanks for sending that over! Going to loop in @SiaraMist and @jc-clark to give this a quick review 💛

@jsoref
Copy link
Contributor Author

jsoref commented Jan 25, 2024

For the title item, https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#onworkflow_dispatch

-When using the workflow_dispatch event, you can optionally specify inputs that are passed to the workflow.
+When using the workflow_dispatch event, you can optionally specify inputs that are passed to the workflow.
+
+This event is only received by workflows on the default branch.

It's documented, but not here, where a reader is likely to look for it.

Instead, you have to be in:
https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#workflow_dispatch

This event will only trigger a workflow run if the workflow file is on the default branch.

I'm not wed to my text. It's just to point out roughly where I'd expect content and roughly what I think is needed.

@SiaraMist
Copy link
Contributor

Thanks for opening this @jsoref! I agree that we should add this information to the Workflow Syntax article as well.

I'd suggest adding a sentence to this section you linked that says something like:

This trigger only receives events when the workflow file is on the default branch.

You or anyone else is welcome to open a PR to add this information.

@SiaraMist SiaraMist added the help wanted Anyone is welcome to open a pull request to fix this issue label Feb 5, 2024
@huyz
Copy link

huyz commented Sep 2, 2024

Is it true that the workflow needs to exist on the default branch?

It seems it's possible to trigger the registration of workflow_dispatch without touching the default branch. See https://stackoverflow.com/a/71057825/161972 and other answers.

Plus, when I click on the Run workflow button, I get to choose the workflow version by ref:
screenshot 2024-09-02T090017Z@2x

Maybe I'm misunderstanding and the distinction is between the existence of the workflow file vs. the workflow_dispatch trigger?

@nguyenalex836
Copy link
Contributor

@huyz Hello! 👋 Your specific question would best be handled by our wonderful support team ✨ Please feel free to reach out to them for assistance!

If there's anything in the documents that you have suggestions for updating, please feel free to open an issue 💛

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
actions This issue or pull request should be reviewed by the docs actions team content This issue or pull request belongs to the Docs Content team help wanted Anyone is welcome to open a pull request to fix this issue waiting for review Issue/PR is waiting for a writer's review
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants