Is there a way to find repositories generated from my template repository?


GitHub already stores information that a repository has been generated using a template. But there is no way to find out all the repos generated from a specific template. In the API there’s a key for every repo called template_repository where you can find out which template repository has been used to generate the repo but there is no way to search for repositories with a certain value for template_repository.
The only solution I have right now is to use Google or other search engines with a query similar to the one below but that will require that the repositories are indexed by those search engines.

site:github.com "generated from sindresorhus/electron-boilerplate"

Essentially I would like something like the forks page (example) but for template repositories.

3 Likes

Hi @dimitarnestorov!

Thanks for this feedback! We’re always working to improve GitHub and the GitHub Support Community, and we consider every suggestion we receive.

Would you mind submitting this through our official product feedback form so that our product team can track your request?

2 Likes

Done :slightly_smiling_face:
Post must be at least 20 characters

1 Like

Any progress with this one?

Eureka! After reading this - Search based on the contents of a repository, the answer was clear! Search by README.md file content!

I always use the name of the repository as the title (# terraform-multienv) which is very common, so if you also do that keep on reading.

Use GitHub’s search engine and provide a unique combination of words that appear in your README.md file. This is how I do it for my template - unfor19/terraform-multienv

I use the latter query to get meaningful search results, by sorting with sort:updated and filtering out my user name -user:USERNAME with -QUALIFIER. The keyword @me is a saved keyword given by GitHub.

Originally posted in https://stackoverflow.com/questions/62943177/how-to-see-how-many-repos-created-from-my-repo-template-github/63910250#63910250

1 Like

Hey @dimitarnestorov, any chance you have some code snippets for how you got the template_repository property in the return result? I have implemented the baptiste-preview for listForOrg() function and it gets the is_template property but template_repository doesn’t appear in the result. I just want to make sure I’m not missing anything. Thanks

const templateTeamAssignment = async (context) => {
  const { github, payload } = context;
  const repo = payload.repository.name;

  console.log("context", context);

  console.log("stackOverflow", await context.github.repos.get(context.repo()));
  console.log(
    "stackOverflow",
    await context.github.repos.listForOrg({
      org: payload.organization.login,
      headers: {
        accept: "application/vnd.github.baptiste-preview+json",
      },
    })
  );
};


I saw it while messing around with the GraphQL API

Hey @dimitarnestorov, thanks for your reply and sorry for the delay in getting back to you. I managed to get it sorted by moving away from octokit/rest and over towards octokit/request.

const templateTeamAssignment = async (context) => {
  const { github, payload } = context;
  const repo = payload.repository.name;

  const repoResult = await github.request("GET /repos/:org/:repo", {
    org: payload.organization.login,
    repo: payload.repository.name,
    mediaType: {
      previews: ["baptiste-preview"],
    },
  });
  console.log("repoResult: ", repoResult);
};