做了一个使用 Notion 自动管理 GitHub Star 的 repo 小工具(via GitHub Actions) - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
爱意满满的作品展示区。
emlcj
V2EX    分享创造

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

  emlcj
lcjnil 2021-10-08 10:43:14 +08:00 7302 次点击
这是一个创建于 1465 天前的主题,其中的信息可能已经有所发展或是发生改变。
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
第 1 条附言    2021-10-08 12:45:36 +08:00

贴一张 Notion 上的图片:

Untitled.png

42 条回复    2021-10-21 10:28:51 +08:00
greatHair
    1
greatHair  
   2021-10-08 11:01:01 +08:00
好东西,帮顶
fkue0487
    2
fkue0487  
   2021-10-08 11:35:56 +08:00
好东西。报错了什么原因啊。

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'
kongkongyzt
    3
kongkongyzt  
   2021-10-08 12:32:30 +08:00
好的惹
emlcj
    4
emlcj  
OP
   2021-10-08 12:41:22 +08:00
@fkue0487 这个报错可以忽略,这个是尝试使用之前缓存下来的数据信息
kongkongyzt
    5
kongkongyzt  
   2021-10-08 12:48:12 +08:00
试了一下, 确实不错, 方便管理我的 github star
KAAAsS
    6
KAAAsS  
   2021-10-08 14:06:28 +08:00
好评!就是管理之前的 Star 好痛苦,快将近 1000……
sd539994389
    7
sd539994389  
   2021-10-08 14:20:22 +08:00
好东西 谢谢分享
SenLief
    8
SenLief  
   2021-10-08 14:23:09 +08:00
挺好的,每次碰到以后可能有用的都会 star 一下,但是后面就找不到了。
ryougifujino
    9
ryougifujino  
   2021-10-08 14:29:08 +08:00
不错
CoderTom
    10
CoderTom  
   2021-10-08 15:50:32 +08:00
不错
longline
    11
longline  
   2021-10-08 16:04:23 +08:00
同二楼报错
raysmond
    12
raysmond  
   2021-10-08 16:58:54 +08:00
支持
emlcj
    13
emlcj  
OP
   2021-10-08 17:15:02 +08:00
@KAAAsS 所以我选择先不管…或者每天发呆的时候标记几个


@longline 那个报错没有任何影响的,可以检查下其他三个环境变量是否都提供了
xdashan
    14
xdashan  
   2021-10-08 17:40:41 +08:00
报错,求指点
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 55

/home/runner/work/github-notion-star/github-notion-star/libs/notion.ts:67
pages.forEach((page) => {
^
TypeError: Cannot read properties of undefined (reading 'plain_text')
at /home/runner/work/github-notion-star/github-notion-star/libs/notion.ts:68:54
at Array.forEach (<anonymous>)
at Notion.addPages (/home/runner/work/github-notion-star/github-notion-star/libs/notion.ts:67:15)
at Notion.fullSyncIfNeeded (/home/runner/work/github-notion-star/github-notion-star/libs/notion.ts:55:18)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
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.
kappa
    15
kappa  
   2021-10-08 17:44:20 +08:00
@emlcj 请问 Tagged 那一栏有什么用?
xdashan
    16
xdashan  
   2021-10-08 17:44:25 +08:00
@xdashan notion 表里有一条空数据,删了同步成功了
kappa
    17
kappa  
   2021-10-08 17:44:57 +08:00
另外 unstar 的项目好像不会被自动删除
emlcj
    18
emlcj  
OP
   2021-10-08 17:59:56 +08:00
@kappa 那个是方便我自己用的。我这边是会给 star 的 repo 打 tag,打完 tag 之后就用这个属性来标记一下。

当然这个属性是可以删除的,不会影响现有功能。
emlcj
    19
emlcj  
OP
   2021-10-08 18:03:18 +08:00
@kappa 对,目前还不支持 unstar 的项目也在 notion 那边同步删除
d5
    20
d5  
   2021-10-08 19:32:44 +08:00
这个很酷,收藏了
yakun4566
    21
yakun4566  
   2021-10-09 09:55:24 +08:00
你们的 github token 怎么提交到仓库里的,我一提交 token 就被自动删除了
emlcj
    22
emlcj  
OP
   2021-10-09 10:49:05 +08:00
@yakun4566 token 是不能放在仓库里面的,得放在项目的 `secrets` 里面。放在仓库里面会导致 token 被泄露的。
yakun4566
    23
yakun4566  
   2021-10-09 11:10:58 +08:00
@emlcj 哦哦,我懂了,谢谢
FrankAdler
    24
FrankAdler  
   2021-10-09 12:01:03 +08:00
好东西,已用上
dengshen
    25
dengshen  
   2021-10-09 17:12:11 +08:00
牛掰格拉斯~ 用上了
mumonitor
    26
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.ts19: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
    27
emlcj  
OP
   2021-10-09 22:04:58 +08:00   1
@mumonitor 是有点问题,可以看下下面的文档,你得打开 database 单独的页面,而不是 fork 的页面
mumonitor
    28
mumonitor  
   2021-10-10 09:41:39 +08:00
@emlcj 赞,搞定了,非常完美,感谢!
Z1106264957
    29
Z1106264957  
   2021-10-10 19:01:00 +08:00
Run npm start

> [email protected] 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
    30
Z1106264957  
   2021-10-10 19:01:21 +08:00
请问这个是为啥啊
daolanfler
    31
daolanfler  
   2021-10-11 10:09:02 +08:00
@Z1106264957 NOTION_API_KEY 在 github repo 的 secrets 设置里添加一下
daolanfler
    32
daolanfler  
   2021-10-11 10:11:30 +08:00
如果有些项目被我 unstar 了,full-sync 会更新吧?
emlcj
    33
emlcj  
OP
   2021-10-11 10:26:56 +08:00
@daolanfler 目前不会的…
bsulike
    34
bsulike  
   2021-10-11 11:10:01 +08:00
试了一下,很棒
czfandyslash
    35
czfandyslash  
   2021-10-11 17:51:44 +08:00
感谢,马上用起来
Z1106264957
    36
Z1106264957  
   2021-10-11 21:19:13 +08:00
@daolanfler 可以问问那个 NOTION_API_KEY 应该如何获取吗,我不太清楚这个操作流程,不知道该如何创建
SingeeKing
    37
SingeeKing  
PRO
   2021-10-12 13:31:00 +08:00
一个小建议,可以把 README / README.txt / README.md / README.rst 也拉下来作为页面的内容,便于后面搜索
luanjia
    38
luanjia  
   2021-10-12 21:19:39 +08:00
赞,已 star
daolanfler
    39
daolanfler  
   2021-10-13 14:01:29 +08:00
@Z1106264957 自己建一个 integration https://www.notion.so/my-integrations 就可以拿到了
xuexiaoaoooo
    40
xuexiaoaoooo  
   2021-10-18 13:51:47 +08:00
请求体内容过大
xuexiaoaoooo
    41
xuexiaoaoooo  
   2021-10-18 13:53:01 +08:00
请求内容过大

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 376
Notion: Get all pages success, count is 191
@notionhq/client warn: request fail {
code: 'validation_error',
message: 'body failed validation: body.properties.Description.rich_text[0].text.content.length should be ≤ `2000`, instead was `5835`.'
}

/home/runner/work/github-notion-star/github-notion-star/node_modules/@notionhq/client/src/errors.ts:240
return new APIResponseError({
^
APIResponseError: body failed validation: body.properties.Description.rich_text[0].text.content.length should be ≤ `2000`, instead was `5835`.
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.insertPage (/home/runner/work/github-notion-star/github-notion-star/libs/notion.ts:77:22)
at fullSync (/home/runner/work/github-notion-star/github-notion-star/main.ts:10:13)
Error: Process completed with exit code 1.
emlcj
    42
emlcj  
OP
   2021-10-21 10:28:51 +08:00
@xuexiaoaoooo 应该是描述过大了…回头我加个 patch 做下限制
关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     2712 人在线   最高记录 6679       Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 28ms UTC 09:00 PVG 17:00 LAX 02:00 JFK 05:00
Do have faith in what you're doing.
ubao snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86