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

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

  •  1
     
  •   emlcj
    lcjnil 2021 年 10 月 8 日 7718 次点击
    这是一个创建于 1588 天前的主题,其中的信息可能已经有所发展或是发生改变。
    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 月 8 日

    贴一张 Notion 上的图片:

    Untitled.png

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

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


    @longline 那个报错没有任何影响的,可以检查下其他三个环境变量是否都提供了
    xdashan
        14
    xdashan  
       2021 年 10 月 8 日
    报错,求指点
    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 月 8 日
    @emlcj 请问 Tagged 那一栏有什么用?
    xdashan
        16
    xdashan  
       2021 年 10 月 8 日
    @xdashan notion 表里有一条空数据,删了同步成功了
    kappa
        17
    kappa  
       2021 年 10 月 8 日
    另外 unstar 的项目好像不会被自动删除
    emlcj
        18
    emlcj  
    OP
       2021 年 10 月 8 日
    @kappa 那个是方便我自己用的。我这边是会给 star 的 repo 打 tag,打完 tag 之后就用这个属性来标记一下。

    当然这个属性是可以删除的,不会影响现有功能。
    emlcj
        19
    emlcj  
    OP
       2021 年 10 月 8 日
    @kappa 对,目前还不支持 unstar 的项目也在 notion 那边同步删除
    d5
        20
    d5  
       2021 年 10 月 8 日
    这个很酷,收藏了
    yakun4566
        21
    yakun4566  
       2021 年 10 月 9 日
    你们的 github token 怎么提交到仓库里的,我一提交 token 就被自动删除了
    emlcj
        22
    emlcj  
    OP
       2021 年 10 月 9 日
    @yakun4566 token 是不能放在仓库里面的,得放在项目的 `secrets` 里面。放在仓库里面会导致 token 被泄露的。
    yakun4566
        23
    yakun4566  
       2021 年 10 月 9 日
    @emlcj 哦哦,我懂了,谢谢
    FrankAdler
        24
    FrankAdler  
       2021 年 10 月 9 日
    好东西,已用上
    dengshen
        25
    dengshen  
       2021 年 10 月 9 日
    牛掰格拉斯~ 用上了
    mumonitor
        26
    mumonitor  
       2021 年 10 月 9 日
    好东西,但是运行 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-stargithub-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 月 9 日   1
    @mumonitor 是有点问题,可以看下下面的文档,你得打开 database 单独的页面,而不是 fork 的页面
    mumonitor
        28
    mumonitor  
       2021 年 10 月 10 日
    @emlcj 赞,搞定了,非常完美,感谢!
    Z1106264957
        29
    Z1106264957  
       2021 年 10 月 10 日
    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 日
    请问这个是为啥啊
    daolanfler
        31
    daolanfler  
       2021 年 10 月 11 日
    @Z1106264957 NOTION_API_KEY 在 github repo 的 secrets 设置里添加一下
    daolanfler
        32
    daolanfler  
       2021 年 10 月 11 日
    如果有些项目被我 unstar 了,full-sync 会更新吧?
    emlcj
        33
    emlcj  
    OP
       2021 年 10 月 11 日
    @daolanfler 目前不会的…
    bsulike
        34
    bsulike  
       2021 年 10 月 11 日
    试了一下,很棒
    czfandyslash
        35
    czfandyslash  
       2021 年 10 月 11 日
    感谢,马上用起来
    Z1106264957
        36
    Z1106264957  
       2021 年 10 月 11 日
    @daolanfler 可以问问那个 NOTION_API_KEY 应该如何获取吗,我不太清楚这个操作流程,不知道该如何创建
    SingeeKing
        37
    SingeeKing  
    PRO
       2021 年 10 月 12 日
    一个小建议,可以把 README / README.txt / README.md / README.rst 也拉下来作为页面的内容,便于后面搜索
    luanjia
        38
    luanjia  
       2021 年 10 月 12 日
    赞,已 star
    daolanfler
        39
    daolanfler  
       2021 年 10 月 13 日
    @Z1106264957 自己建一个 integration https://www.notion.so/my-integrations 就可以拿到了
    xuexiaoaoooo
        40
    xuexiaoaoooo  
       2021 年 10 月 18 日
    请求体内容过大
    xuexiaoaoooo
        41
    xuexiaoaoooo  
       2021 年 10 月 18 日
    请求内容过大

    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 日
    @xuexiaoaoooo 应该是描述过大了…回头我加个 patch 做下限制
    关于     帮助文档     自助推广系统     < href="https://blog.v2ex.com/" class="dark" target="_blank">博客     API     FAQ     Solana     1049 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 29ms UTC 17:57 PVG 01:57 LAX 09:57 JFK 12:57
    Do have faith in what you're doing.
    ubao msn 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