Search code examples
github-apinetlifynetlify-cms

Is there a way to specify the branch Tree while using github as the backend for netlify CMS?


I'm using netlifyCMS and I've just added github authentication which works alright. The issue is when I try accessing my collection, all of them are empty and the reason is the github API request being made to read the content is wrong. Here is the GET request being made https://api.github.com/repos/CodeForAfrica/ui/git/trees/main:content/donors However, since I'm in a monorepo the path should be ..trees/main:apps/codeforafrica/content/donors

The only location I see the branch being set is in the config file

backend: {
    name: "github",
    branch: "main",
    repo: "CodeForAfrica/ui",
    proxy_url: "http://localhost:8081/api/v1", // Set proxy to work on local repo
  },

If I try doing

backend: {
    name: "github",
    branch: "main:apps/codeforafrica",
    repo: "CodeForAfrica/ui",
    proxy_url: "http://localhost:8081/api/v1", // Set proxy to work on local repo
  },

The request is now

https://api.github.com/repos/CodeForAfrica/ui/git/trees/main:apps/codeforafrica:content/donors

Which is wrong. Any ideas on how to resolve this?


Solution

  • There isn't a way to set this; instead, you solve this by setting the correct file or folder location. In my case, I only had to set file: "apps/codeforafrica/content/pages/index.md" instead of file: "content/pages/index.md"