自动化涉及第三方存储库的GitHub工作流程

发布于 2025-01-30 04:45:18 字数 393 浏览 2 评论 0原文

我有一个github repo myrepo,它扫描了另一个repo 其repo的内容,并将它们转换为JSON文件。详细信息并不是那么重要,只是myrepo使用nodejs并将保留为subpoule。许可证这不是问题。

我想实现的是,当他们的repo合并到mainmyrepo magally 更新并构建新文件。我想使用现有的基础架构,例如GitHub动作,NetLify构建过程等。

您将如何处理?

我不希望为 magical 部分提供详细的解决方案,而是在寻找一些指针,这让我开始了。

I have a GitHub repo myRepo that scans the contents of another repo theirRepo and converts them to JSON files. The details aren't really that important, just so much that myRepo uses nodeJS and holds theirRepo as a submodule. Licensewise this is not a problem.

What I'd like to achieve is that, when theirRepo merges into main, myRepo magically updates and builds the new files. I'd like to use existing infrastructures such as GitHub actions, Netlify build processes etc.

How would you approach this?

I don't expect a detailed solution for the magical part, but am rather looking for a few pointers, something that gets me started.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

七度光 2025-02-06 04:45:18

由于GitHub Action(AFAIK)当前不允许基于其他存储库的更改(除非您控制另一个存储库的工作流程)触发事件。

的其他repo中的文件更改

我不熟悉节点

  • ,但是,根据项目文化的不同,以下文件可能会在新版本/主分支更新期间更改: package-lock.json
  • changelog.md(用于语义版本,)

这是一个粗略的近似值,您可能还需要确定每个合并PR可能会更改的多个文件。

基于CRON的工作

每N小时/分钟或其他时间间隔运行您的工作,以检查更改。

仅在另一个回购中的文件更改中的文件时,使用缓存

才能运行您的操作,这是这些行:

steps:
  - run: curl <path to file> -o output1
  - run: curl <path to file2> -o output2
  - name: Cache
    uses: actions/cache@v3
    id: cache
    with:
      key: ${{ hashFiles(”output1”, “output2”) }}
  - name: Update repo
    if: steps.cache.output.cache-hit != “true”
    run: <do your stuff>

As GitHub Actions (AFAIK) does not currently allow to trigger events based on changes in other repositories (unless you control another repository’s workflows) one might have to hack a little bit.

File change in OtherRepo

I’m not familiar with Node, but, depending on the project culture following files might change during the new release/main branch update:

  • package-lock.json
  • CHANGELOG.md (for semantic versioning)

This is a rough approximation, you might also want to identify multiple files likely to change with each merged PR.

Cron based jobs

Run your job every N hours/minutes or another time interval to check for changes.

Use caching

Run your action only when files in another repo change, something along these lines:

steps:
  - run: curl <path to file> -o output1
  - run: curl <path to file2> -o output2
  - name: Cache
    uses: actions/cache@v3
    id: cache
    with:
      key: ${{ hashFiles(”output1”, “output2”) }}
  - name: Update repo
    if: steps.cache.output.cache-hit != “true”
    run: <do your stuff>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文