Home
Support Forums

Onprebuild event - its working but file not written to github

Hi, am I testing out the onPrebuild event and it looks great… except writing a new markdown file to github.
After the deploy, the new file is created (using fs-extra) and the page with the content of that file is accessible but the md-file its not pushed to github.
How can I push that file to github, is it a permission or am I missing something… thank you.

Hi @alainb,

Netlify clones your repo to its server and processes it. It does not have write access to repo and anything generated during the build is lost after the build is done (except for files that are published). I’m not sure what the use case is, but I’m afraid what you’re trying might not be really possible.

Thank you.
Use case: goHugo with content from api. Hugo can’t create separarte (individual) pages from data (api, json,…).
So the prebuild event could solve that by creating md-files and push them to git.
But its working, except i dont have the md-files / source files.

Yes, the preBuild event can handle what you’re trying, except it can’t write files to Git. You should probably try using GitHub Actions to achieve this as there are actions that can write to your repo.

1 Like