爱意满满的作品展示区。
emlcj

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

  •  1
     
  •   emlcj ·
    lcjnil · Oct 8, 2021 · 8643 views
    This topic created in 1851 days ago, the information mentioned may be changed or developed.
    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
    Supplement 1  ·  Oct 8, 2021

    贴一张 Notion 上的图片:

    Untitled.png

    42 replies  •  2021-10-21 10:28:51 +08:00
    greatHair
    greatHair
    Oct 8, 2021
    1
    好东西,帮顶
    Pinnx
    Pinnx
    Oct 8, 2021
    2
    好东西。报错了什么原因啊。

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


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

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

    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
    emlcj
    OP
    Oct 21, 2021
    42
    @xuexiaoaoooo 应该是描述过大了…回头我加个 patch 做下限制
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   5305 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 68ms · UTC 01:29 · PVG 09:29 · LAX 17:29 · JFK 20:29
    ♥ Do have faith in what you're doing.