用于将静态网站从git发布到ipfs的类似cd的工具
ipfs-publish的Python项目详细描述
ipfs发布
Continuous Delivery of static websites from Git to IPFS
关于
这是一个工具,旨在实现从git存储库到ipfs的静态网页的自动发布。 它由两部分组成:小型web服务器和管理cli。
web服务器公开一个端点,您可以将其用作git的webhook。当钩子被调用时,它会克隆 您的repo,构建它(如果需要的话),将它添加到ipfs节点(如果配置了的话,请固定它)并发布新的ipfs地址 在配置的ipns名称下。
cli用于管理repo。
功能
- 忽略文件-
.ipfs_publish_ignore
文件指定在将repo添加到ipfs之前应删除的条目 - 发布目录-只能发布回购协议中的特定子目录
- 发布特定分支-您可以指定应从回购中发布哪个分支
- 构建脚本-在添加到ipfs之前,可以在克隆的repo中运行脚本/二进制文件
- 发布脚本之后-发布到IPFS之后,将使用创建的IPFS地址的参数运行此脚本
Git提供商
目前webhook支持泛型模式,其中repo的secret作为url参数传递。
github还有一种特殊的模式,其中secret应该配置为webhook配置的一部分。
警告
此工具不是公共服务,只应与受信任的git repo一起使用。 由于脚本的运行时环境不是 与你的机器隔离!
安装
要求
- Python 3.7及更高版本
- 吉特
- 转到ipfs守护进程
- 具有公共IP的类Unix计算机
PIP
您可以使用pip
:
$ pip install ipfs-publish
然后,您可以使用命令ipfs-publish
来管理您的repo和/或启动webhook的服务器。
Docker
有一个官方的Docker图片,名字是:auhau/ipfs-publish
运行ipfs发布的最简单方法是使用docker compose。下面是它的配置示例:
version:'3'services:ipfs:image:ipfs/go-ipfs:v0.4.18volumes:-/data/ipfs# or you can mount it directly to some directory on your systemipfs-publish:image:auhau/ipfs-publishenvironment:IPFS_PUBLISH_CONFIG:/data/ipfs_publish/config.tomlIPFS_PUBLISH_VERBOSITY:3IPFS_PUBLISH_IPFS_HOST:ipfsIPFS_PUBLISH_IPFS_PORT:5001volumes:-/data/ipfs_publishdepends_on:-ipfsports:-8080:8000
有关详细信息,请参见documentation。
用法
# Add new repo $ ipfs-publish add [?] Git URL of the repo: https://github.com/auhau/auhau.github.io [?] Name of the new repo: github_com_auhau_auhau_github_io [?] Do you want to publish to IPNS? (Y/n): [?] Path to build binary, if you want to do some pre-processing before publishing: [?] Path to after-publish binary, if you want to do some actions after publishing: [?] Directory to be published inside the repo. Path related to the root of the repo: / Successfully added new repo! Use this URL for you webhook: http://localhost:8080/publish/github_com_auhau_auhau_github_io Also set this string as your hook's Secret: NIHT4785CVFT358GFE08RDAZG Your IPNS address: /ipns/QmRTqaW3AJJXmKyiNT7MqqZ4VjGtNNxPyTkgo3Q7pmoCeX/ # List current enabled repos $ ipfs-publish list github_com_auhau_auhau_github_io # Show details of repo $ ipfs-publish show github_com_auhau_auhau_github_io github_com_auhau_auhau_github_io Git URL: https://github.com/auhau/auhau.github.io Secret: EAHJ43UYT7LUEM4QFRZ4IFAXL IPNS key: ipfs_publishg_github_com_auhau_auhau_github_io IPNS lifetime: 24h IPNS ttl: 15m IPNS address: /ipns/QmRTqaW3AJJXmKyiNT7MqqZ4VjGtNNxPyTkgo3Q7pmoCeX/ Last IPFS address: None Webhook address: http://localhost:8080/publish/github_com_auhau_auhau_github_io # You can manually publish repo $ ipfs-publish publish github_com_auhau_auhau_github_io # Starts HTTP server & IPNS republishing service $ ipfs-publish server & Running on http://localhost:8080 (CTRL + C to quit)
贡献
欢迎大家踊跃参与,踊跃投稿!Open an issue或提交prs。
有关prs和开发技巧,请参见contribution guideline。