Programmatically add files to a GitHub download page

前端 未结 4 1642
被撕碎了的回忆
被撕碎了的回忆 2021-02-18 22:57

[[Please note that Github has changed a lot since this question was first asked; instead of \"download page\" read \"new release\".]]

I generate PDF documentation as par

4条回答
  •  悲哀的现实
    2021-02-18 23:01

    I take it that by "GitHub download page", the owner means a repo–more specifically a branch– that can be downloaded via the "download" button.

    If you want to add a file to a repo using the API, you will have to become familiar with the process described here: https://developer.github.com/v3/git/

    It's not the easiest process in the world, but mastering it will force you to understand the concepts of blobs, trees, commits and references, amongst others.

    You can't just "send a file" to a repo because you're working with Git, and Git has some "internal expectations" that you just can't ignore (it's impossible to think of GitHub as some sort of host that you can ftp). Explaining the flow required to create a file in a GitHub repo is certainly beyond the scope of the original question, but to provide a clear answer: no, it's not possible to programmatically upload a file on GitHub, but yes it is possible to programmatically push a file on GitHub".

    There's a PHP library named GitHubTreePHP that lets you automate the process (Disclaimer: I wrote it).

提交回复
热议问题