Run action on repo creation from template #25748
-
I would like to generate scoped NodeJs repo from a template. I have the template wired up with an action that already has the ability to run and create the package.json, then commit that to the repo. What event can I trigger the action on so that when somebody clicks the “use this template” it will run the action that finishes the setup? I’ve tried to use:
but that doesn’t seem to be the correct workflow. |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments
-
Hi @themoch , I would recommend you using create event. Add on: create to the workflow yml which could create package.json in your template repo .
After done this and clicking on “use the template”, a new repo will be created . And a workflow run on: create will be triggered. Please kindly let me know whether this could work for you . |
Beta Was this translation helpful? Give feedback.
-
It worked! I’m looking over the other documentation about events for Actions (https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#onevent_nametypes) and the value they give is Thank you for your reply. |
Beta Was this translation helpful? Give feedback.
-
Hi @themoch , I want to provide some explanation. The doc you mentioned before links to on.<event_name>.types , the “created” is the type name of release event. All the Activity types of events are in past tense. I have recommended you to use create event, the “create” is the name of an event. |
Beta Was this translation helpful? Give feedback.
-
I understand completely. It would be nice if this page contained a list of events at the top or in the navigation for quick reference. https://help.github.com/en/actions/reference/events-that-trigger-workflows#create-event-create |
Beta Was this translation helpful? Give feedback.
-
Oh, there is a good idea. We will consider it. |
Beta Was this translation helpful? Give feedback.
-
Hi @yanjingzhu, is this still accurate advice? I have: But when a user creates a repo from the template, it doesn’t run Any thoughts? |
Beta Was this translation helpful? Give feedback.
-
Doesn’t work for me either. As a work-around, one could have Maybe with an |
Beta Was this translation helpful? Give feedback.
Hi @themoch ,
I would recommend you using create event.
Add on: create to the workflow yml which could create package.json in your template repo .
After done this and clicking on “use the template”, a new repo will be created . And a workflow run on: create will be triggered.
Please kindly let me know whether this could work for you .