git - 有没有办法使用逻辑 AND 在 GitHub 操作中组合推送标准?

标签 git github github-actions

在 GitHub 操作中 'Events that trigger workflows' documentation列出了多种方式,例如在特定分支和特定路径更改上。有没有办法使用AND将这两者结合起来?
据我了解,如果推送是到主分支或特定路径,以下语法将触发运行。是否可以说必须同时满足两个条件才能触发操作?

on:
  push:
    branches:
    - master
    paths:
    - 'app/*'

Note: I am not looking for a hacky solution like letting it trigger on the path and then checking in the step if the branch is the master branch. I know that this is possible, but you would need to do it for each step and it isn't elegant at all.

最佳答案

我发现的最接近的解决方法是这样的

name: only on master but when the POM changes

on:
  push:
    paths:
      - 'pom.xml'

jobs:
  build_pom:
    if: ${{ github.ref == 'refs/heads/master' }}
    runs-on: ubuntu-latest
    steps:
    [...]

关于git - 有没有办法使用逻辑 AND 在 GitHub 操作中组合推送标准?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64621707/

相关文章:

git - 从 master 分支构建到 gh-pages 分支

github - hyperledger-fabric-readthedocs.io 教程,开发人员的链码,找不到包 shim - 已修复

GitHub 将存储库更改为错误的语言

git - 如果包含特殊字符,如何在 Git 中设置用户名?

svn - 如何将变更集从 hg 存储库导出到 svn 存储库

git "shallow clone + unshallow"与 "normal clone"

github-actions - 每个步骤都已经定义了使用或运行键,但仍然收到错误

安卓工作室 : Can't start Git

r - 如何通过 GitHub Actions 向 CRAN 提交 R 包?

docker - 从 Docker GitHub 操作将二进制文件添加到 PATH 以供后续工作流程步骤使用