V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
爱意满满的作品展示区。
emlcj
V2EX  ›  分享创造

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

  •  1
     
  •   emlcj · 59 天前 · 3418 次点击
    这是一个创建于 59 天前的主题,其中的信息可能已经有所发展或是发生改变。
    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 条附言  ·  59 天前

    贴一张 Notion 上的图片:

    Untitled.png

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

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


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

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

    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
       46 天前
    @xuexiaoaoooo 应该是描述过大了…回头我加个 patch 做下限制
    关于   ·   帮助文档   ·   API   ·   FAQ   ·   我们的愿景   ·   广告投放   ·   感谢   ·   实用小工具   ·   2273 人在线   最高记录 5497   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 22ms · UTC 15:47 · PVG 23:47 · LAX 07:47 · JFK 10:47
    ♥ Do have faith in what you're doing.