0

I used github to set up an heroku application using this link, in my application I create some new content (this is a wiki-like application where some new articles are created in the apps, no database involved the new articles are markdown files in the server). When the app is running, the articles are saved to the distant heroku server but if I do nothing, when I update the github repo and I rebuild the heroku app I loose every article I wrote.

My question is how can I manually (or automatically) push the new articles present server side to the github repo ? I can log in bash using heroku run bash but once I am here, I am not in a github repo so I can't commit to save the articles I added.

  • 1
    "no database involved the new articles are markdown files in the server"—this isn't going to work on Heroku. You _must_ save this content somewhere off the dyno, e.g. in a database or something like Azure Blob Storage. Heroku's ephemeral filesystem will cause the new files to be lost every time you update (as you have seen) but also at unpredictable, frequent intervals, during regular restarts. This happens at least once per day. – ChrisGPT was on strike Nov 02 '21 at 13:27
  • yes but this is why I wanted to trigger commits regularly, possibly linked to a webhook (I am a beginner at this) or manually. Is this possible or do I really have to give up heroku ? Or another way to say this linked to https://stackoverflow.com/questions/50421061/can-i-use-a-file-based-database-on-heroku is can we use github instead of amazon S3 to for assets and file upload ? –  Nov 02 '21 at 14:29
  • Committing changes on your dyno and pushing into GitHub is extremely awkward and error-prone. Heroku has designed their service with an ephemeral filesystem deliberately: it is [part of an overall strategy](https://12factor.net/disposability). "do I really have to give up heroku ?"—no, but if you want to use Heroku you do need to use it as it is designed. "can we use github instead of amazon S3 to for assets and file upload ?"—this may be _possible_ but it would be using a screwdriver to hammer in a nail. GitHub isn't for file storage and hosting, it's for revision control. – ChrisGPT was on strike Nov 02 '21 at 15:12
  • I don't really agree with your comment on github, I mean I am using it to store articles of a wiki, they are small text files that are meant to be version controlled (for instance wikipedia does version control that is not so different from github on all of its articles). and hosting them on github would allow me to roll back if needed. –  Nov 02 '21 at 15:17
  • GitHub stores _respositories_. If you have a _repository_ you can store it on GitHub. But it's not for arbitrary file storage or hosting. But if you're going to store Markdown files in GitHub and try to host them... why not just use GitHub Pages? Or GitHub's own wiki (which uses [Gollum](https://github.com/gollum/gollum) under the hood) if you need to let users edit them? Running an application on Heroku and trying to push files into a GitHub repository as your database is extremely awkward. You'd likely have to use the GitHub API since you can't rely on the local filesystem. – ChrisGPT was on strike Nov 02 '21 at 15:18
  • 1
    Decide whether your "store articles as local files" or "use Heroku" goal is more important. – ChrisGPT was on strike Nov 02 '21 at 15:22
  • github page is static, I can't use them and edit articles online. Yes maybe I can change the whole wiki and use gollum but I would have to redo all my articles and also I like the one I use so I don't want to change, there are a lot of things that are not the same in gollum. I don't really care if I use Heroku or any other nodejs service provider but I found heroku to be nice. –  Nov 02 '21 at 15:29

0 Answers0