ARTICLE DETAIL

资讯详情

深耕郑州网站建设与运营推广的一线实战洞察。

如何把 n8n-workflows 的 GitHub Pages 静态站点构建脚本跑通?

如何把 n8n-workflows 的 GitHub Pages 静态站点构建脚本跑通? 如何把 n8n-workflows 的 GitHub Pages 静态站点构建脚本跑通【免费下载链接】n8n-workflowsall of the workflows of n8n i could find (also from the site itself)项目地址: https://gitcode.com/GitHub_Trending/n8nworkflo/n8n-workflowsn8n-workflows 仓库在docs/目录下放了一个可浏览、可搜索的静态站点通过 GitHub Pages 对外发布。站点里的静态数据搜索索引、统计、分类与集成列表不是手写的而是由 scripts/ 下的 Python 脚本生成的先建 SQLite 工作流数据库再由generate_search_index.py产出docs/api/下的 JSON最后用update_github_pages.py完成 Pages 配置并校验部署文件是否齐全。本文把这条链路在本地完整跑一遍。前提本地已有 Python 3.9README.md 的 Prerequisites 还要求 pip 和 100MB 磁盘空间所有命令都在仓库根目录执行。准备环境并生成工作流数据库scripts/generate_search_index.py 和 scripts/update_readme_stats.py 都从仓库根目录的workflow_db.py导入WorkflowDatabase并读取database/workflows.db。这个数据库文件需要先生成pip install -r requirements.txt python run.py --reindexrequirements.txt 注释说明核心依赖兼容 Python 3.9–3.12。如果database/workflows.db不存在就跳过这一步直接跑索引脚本脚本会打印Database not found: database/workflows.db提示Run python run.py --reindex first to create the database然后以退出码 1 结束——这是脚本自带的第一道检查点看到它就说明先执行--reindex。生成静态搜索索引python scripts/generate_search_index.py这个脚本做的事按源码顺序是从database/workflows.db读取全部工作流limit10000和统计信息为每条工作流生成searchable_text名称、描述、文件名、集成、标签的拼接小写串和分类。分类优先取context/search_categories.json中已有的分配该文件不存在时打印Warning: search_categories.json not found, using integration-based categorization并回退到按集成归属分类不影响运行向docs/api/写入四个文件search-index.json完整索引version为1.0包含stats、categories、integrations、workflows四部分stats.json仅统计部分便于快速加载categories.json分类列表integrations.json按出现次数排序的前 50 个集成。运行成功的输出形如具体数值以你本地数据库为准Search index generated successfully: 4343 workflows indexed 20 categories 50 popular integrations Files saved to: docs/api Static search index ready for GitHub Pages!验证方式确认docs/api/下出现了上述四个 JSON且search-index.json中每条 workflow 带有name、filename、category、download_url等字段。跑 update_github_pages.py 完成配置与校验python scripts/update_github_pages.py先说副作用scripts/update_github_pages.py 没有命令行筛选参数每次运行会完整执行四步并写入docs/下的多个文件更新docs/index.html页脚中Last updated: Month Year文本为当前月/年并向head插入一个meta namelast-updated ...标签已存在时不重复插入重写docs/api/metadata.json内容为version: 2.0.1、deployment_type: github_pages及当前时间戳若docs/api/stats.json存在则刷新其中的last_updated字段重新生成 docs/_config.ymltheme: null、baseurl: /n8n-workflows、url: https://zie619.github.io并排除workflows/、scripts/、src/、k8s/、helm/等目录、docs/.nojekyll和docs/404.html把docs/index.html以及docs/js/app.js、docs/js/search.js中的绝对路径引用href/css/、src/js/、fetch(/api/等替换为相对路径保证站点在/n8n-workflows子路径下能正常加载资源。最后一步是结构校验检查这 8 个必需文件是否存在docs/index.html docs/css/styles.css docs/js/app.js docs/js/search.js docs/api/search-index.json docs/api/stats.json docs/api/categories.json docs/api/integrations.json每个文件打印一行✅ Found: ...或❌ Missing: ...。全部存在时输出✅ All required files present for GitHub Pages deployment ✨ GitHub Pages setup complete!此时脚本还会打印站点地址https://zie619.github.io/n8n-workflows/并提示 push 到 GitHub 后可能需要几分钟页面才更新。如果校验发现缺失文件脚本会给出重新生成的提示命令python workflow_db.py --index --force、python create_categories.py、python scripts/generate_search_index.py此时先确认前一步的索引脚本是否在仓库根目录成功跑完再按提示补齐缺失文件。结果验证判断整条链路跑通看三点docs/api/metadata.json的内容变为带last_updated、version: 2.0.1、deployment_type: github_pages的新时间戳——这是脚本真实执行过的直接证据校验环节打印All required files present for GitHub Pages deployment没有❌ Missing行把docs/目录的变化提交并推送到仓库后访问 https://zie619.github.io/n8n-workflows/ 能看到站点。可选分支同步 README 统计数字如果还需要把 README.md 里写死的工作流数量、集成数等数字刷新为数据库最新值可以运行python scripts/update_readme_stats.py副作用是改写README.md本体脚本用正则匹配文中的数字段落并替换成功后打印各项当前统计值与README.md successfully updated with latest statistics!。它依赖同一个database/workflows.db但不产出任何docs/下的站点文件与静态站构建相互独立不需要时跳过即可。已知限制两个主脚本都没有过滤参数update_github_pages.py每次都会完整执行时间戳、配置、URL 修正和校验四个步骤无法只跑其中某一步。校验环节只判断文件是否存在不判断内容是否最新只改了workflows/数据而不重跑generate_search_index.py时docs/api/里仍是旧内容站点也不会变。Python 版本要求在不同文档中不完全一致README.md 与 requirements.txt 按 3.9 / 3.9–3.12 描述DEPLOYMENT.md 的 “Python Direct Deployment” 一节写的是 3.11。跑本文这条构建链路时按 README 的 3.9 准备即可两条来源的差异以实际运行报错为准。【免费下载链接】n8n-workflowsall of the workflows of n8n i could find (also from the site itself)项目地址: https://gitcode.com/GitHub_Trending/n8nworkflo/n8n-workflows创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考
返回列表