GitHub Actions: trigger on template repository clone

Template repository: https://help.github.com/en/articles/creating-a-template-repository

Would be cool to be able to trigger an Action inside the cloned repository, right after cloning.

It can run the setup steps and preare the repository for actual use.

For example, if it was a template repository for a node project. It could then change the name in the package.json to match the target repository name automatically.

11 Likes

So interested on this feature too.
It could be very helpful in order to create templates ready-to-use and avoid configuration advises on template.

My proposal is a little bit different. I thing triggers is not really needed because could be accomplish by internal GitHub behaviour.

I think that could be useful a configuration file like .on_template_cloned.* , a file that will be executed on event happens. Then, remove this file and commit the result (the repository ready to use).

A more advanced solution could be create an schema (ex. JSON Schema) with replacement rules & scripts to run.

Example:

{
  "replacements": [
    {
      "replace": " origin_value",
      "with": "target_value"
    },
...
  ],
  "runnables": [
    "script.sh"
    "job.yml",
    ...
  ]
}

FYI  @moltar :

Nowadays, I’m using the following approach to accomplish that missing ‘feature’:

https://gist.github.com/rjlopezdev/f2c2ab0db522aad87c98fb1dc2e4ef14

Correspondig to this repository template: https://github.com/rjlopezdev/nestjs-lib-starter

Waiting for this feature too.

I was expecting that using a simple action with “on: push branch: -master” will be sufficent to run the workflow…

I’ve solved it this way: https://gist.github.com/moltar/afe0e541ac87ed07f1454520683140de

2 Likes

That was my repository using metasplod on windows which I used my phone which is an android. I went through termux to use. I was trying to see why my phone was acting up. I felt like someone was spyin on me so I figured they would try to clone my computer.

It really would a be very nice github action feature

+1 for this feature. Having a templating action would ease workflows