如何在 github 操作中考虑 push: 和 pull_request: 的共同路径?

How to factor `paths:` in common for push: and pull_request: in github actions?

我想在其中考虑公共路径:

on:
  push:
    # Run only on changes on these files
    paths:
      - 'lib/**.nim'
      - 'doc/**.rst'
      - 'doc/nimdoc.css'
      - '.github/workflows/ci_docs.yml'

  pull_request:
    # Run only on changes on these files
    paths:
      - 'lib/**.nim'
      - 'doc/**.rst'
      - '.github/workflows/ci_docs.yml'

github 上的文档提到了 [push, pull_request],但如果我们有路径节点,它就不起作用。避免代码重复的语法是什么?

(提前为与 https://github.community/t/how-to-factor-paths-in-common-for-push-and-pull-request/115967 的交叉发布道歉,如果我得到任何答案,我会在另一端更新)

如果我对你的问题的理解正确,你是在问如何列出多个事件的公共路径,如 pushpull_request 运行 文件路径 lib/**.nim', 'doc/**.rst', '.github/workflows/ci_docs.yml' 目前不可能。

恭敬地,在两个地方都有列表并没有太多重复,并且出于 GitHub 方面的某些实施细节原因,很可能是这样。

如果您想阅读更多官方文档:https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#onpushpull_requestpaths

这是一个您可能想尝试的示例。 @xandermonkey 链接的文档中也概述了类似的方法。

on:
  push:
  pull_request:
    # Run only on changes on these files
    paths:
      - 'lib/**.nim'
      - 'doc/**.rst'
      - '.github/workflows/ci_docs.yml'