做了一个使用 Notion 自动管理 GitHub Star 的 repo 小工具(via GitHub Actions)

2021-10-08 10:43:14 +08:00
 emlcj
Hi,我做了一个使用 Notion 自动管理 GitHub Star 的小工具,会借助 GitHub Actions 去同步(全量或者增量) Star 到 Notion 的 database,并且可以在 Notion 上进行一些标记(比如打标签、设置批注等),大家有兴趣可以试用一下~

文档在: https://www.notion.so/lcj/ed1a50d5b57b4bca8a8ec3509c38f5ed
Showcase 在: https://www.notion.so/lcj/597ca47341074f10a8a754378f470411?v=0140b25047c84ec8bc562e6106937b75
5265 次点击
所在节点    分享创造
42 条回复
yakun4566
2021-10-09 09:55:24 +08:00
你们的 github token 怎么提交到仓库里的,我一提交 token 就被自动删除了
emlcj
2021-10-09 10:49:05 +08:00
@yakun4566 token 是不能放在仓库里面的,得放在项目的 `secrets` 里面。放在仓库里面会导致 token 被泄露的。
yakun4566
2021-10-09 11:10:58 +08:00
@emlcj 哦哦,我懂了,谢谢
FrankAdler
2021-10-09 12:01:03 +08:00
好东西,已用上
dengshen
2021-10-09 17:12:11 +08:00
牛掰格拉斯~ 用上了
mumonitor
2021-10-09 20:19:28 +08:00
好东西,但是运行 workflow 的时候报错。

猜测是 Notion Database ID 有问题,我的页面 url 是:
https://www.notion.so/Github-Notion-Star-abcb96c2414a427ea3d1f96a2a72f843

尝试了:Github-Notion-Star-abcb96c2414a427ea3d1f96a2a72f843 和 abcb96c2414a427ea3d1f96a2a72f843 都不行。。。

Notion: error from recover cache Error: ENOENT: no such file or directory, open '/home/runner/work/github-notion-star/github-notion-star/.cache/notion-page.json'
at Object.openSync (node:fs:585:3)
at Object.readFileSync (node:fs:453:35)
at Object.get (/home/runner/work/github-notion-star/github-notion-star/libs/cache.ts:18:31)
at new Notion (/home/runner/work/github-notion-star/github-notion-star/libs/notion.ts:19:22)
at Object.<anonymous> (/home/runner/work/github-notion-star/github-notion-star/libs/notion.ts:132:23)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Module.m._compile (/home/runner/work/github-notion-star/github-notion-star/node_modules/ts-node/src/index.ts:1225:23)
at Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Object.require.extensions.<computed> [as .ts] (/home/runner/work/github-notion-star/github-notion-star/node_modules/ts-node/src/index.ts:1228:12)
at Module.load (node:internal/modules/cjs/loader:981:32) {
errno: -2,
syscall: 'open',
code: 'ENOENT',
path: '/home/runner/work/github-notion-star/github-notion-star/.cache/notion-page.json'
}
Notion: restored from cache, count is 0
Github: Start to get all starred repos, limit is 20
Notion: Start to get all pages
Github: Get all starred repos success, count is 29
@notionhq/client warn: request fail {
code: 'object_not_found',
message: 'Could not find database with ID: abcb96c2-414a-427e-a3d1-f96a2a72f843.'
}

/home/runner/work/github-notion-star/github-notion-star/node_modules/@notionhq/client/src/errors.ts:240
return new APIResponseError({
^
APIResponseError: Could not find database with ID: abcb96c2-414a-427e-a3d1-f96a2a72f843.
at Object.buildRequestError (/home/runner/work/github-notion-star/github-notion-star/node_modules/@notionhq/client/src/errors.ts:240:12)
at Client.request (/home/runner/work/github-notion-star/github-notion-star/node_modules/@notionhq/client/src/Client.ts:157:15)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at Notion.fullSyncIfNeeded (/home/runner/work/github-notion-star/github-notion-star/libs/notion.ts:49:54)
at async Promise.all (index 1)
at fullSync (/home/runner/work/github-notion-star/github-notion-star/main.ts:6:5)
Error: Process completed with exit code 1.
emlcj
2021-10-09 22:04:58 +08:00
@mumonitor 是有点问题,可以看下下面的文档,你得打开 database 单独的页面,而不是 fork 的页面
mumonitor
2021-10-10 09:41:39 +08:00
@emlcj 赞,搞定了,非常完美,感谢!
Z1106264957
2021-10-10 19:01:00 +08:00
Run npm start

> notionstar@1.0.0 start
> ts-node ./main.ts

Notion: error from recover cache Error: ENOENT: no such file or directory, open '/home/runner/work/github-notion-star/github-notion-star/.cache/notion-page.json'

/home/runner/work/github-notion-star/github-notion-star/main.ts:30
ENVS.forEach((env) => {
at Object.openSync (node:fs:585:3)
^
AssertionError [ERR_ASSERTION]: NOTION_API_KEY must be added
at /home/runner/work/github-notion-star/github-notion-star/main.ts:31:11
at Object.readFileSync (node:fs:453:35)
at Array.forEach (<anonymous>)
at Object.get (/home/runner/work/github-notion-star/github-notion-star/libs/cache.ts:18:31)
at Object.<anonymous> (/home/runner/work/github-notion-star/github-notion-star/main.ts:30:6)
at new Notion (/home/runner/work/github-notion-star/github-notion-star/libs/notion.ts:19:22)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.<anonymous> (/home/runner/work/github-notion-star/github-notion-star/libs/notion.ts:132:23)
at Module.m._compile (/home/runner/work/github-notion-star/github-notion-star/node_modules/ts-node/src/index.ts:1225:23)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.m._compile (/home/runner/work/github-notion-star/github-notion-star/node_modules/ts-node/src/index.ts:1225:23)
at Object.require.extensions.<computed> [as .ts] (/home/runner/work/github-notion-star/github-notion-star/node_modules/ts-node/src/index.ts:1228:12)
at Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Object.require.extensions.<computed> [as .ts] (/home/runner/work/github-notion-star/github-notion-star/node_modules/ts-node/src/index.ts:1228:12)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.load (node:internal/modules/cjs/loader:981:32) {
errno: -2,
syscall: 'open',
code: 'ENOENT',
path: '/home/runner/work/github-notion-star/github-notion-star/.cache/notion-page.json'
}
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:79:12)
Notion: restored from cache, count is 0
Error: Process completed with exit code 1.
Z1106264957
2021-10-10 19:01:21 +08:00
请问这个是为啥啊
daolanfler
2021-10-11 10:09:02 +08:00
@Z1106264957 NOTION_API_KEY 在 github repo 的 secrets 设置里添加一下
daolanfler
2021-10-11 10:11:30 +08:00
如果有些项目被我 unstar 了,full-sync 会更新吧?
emlcj
2021-10-11 10:26:56 +08:00
@daolanfler 目前不会的…
bsulike
2021-10-11 11:10:01 +08:00
试了一下,很棒
czfandyslash
2021-10-11 17:51:44 +08:00
感谢,马上用起来
Z1106264957
2021-10-11 21:19:13 +08:00
@daolanfler 可以问问那个 NOTION_API_KEY 应该如何获取吗,我不太清楚这个操作流程,不知道该如何创建
SingeeKing
2021-10-12 13:31:00 +08:00
一个小建议,可以把 README / README.txt / README.md / README.rst 也拉下来作为页面的内容,便于后面搜索
luanjia
2021-10-12 21:19:39 +08:00
赞,已 star
daolanfler
2021-10-13 14:01:29 +08:00
@Z1106264957 自己建一个 integration https://www.notion.so/my-integrations 就可以拿到了
xuexiaoaoooo
2021-10-18 13:51:47 +08:00
请求体内容过大

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/806349

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX