首页 > 解决方案 > Github Actions - 当分支中的特定目录获得更新时,如何触发推送?

问题描述

我希望我的工作流仅在对特定目录进行更改时触发推送。这可能吗,我错过了什么?我试着做一些你在下面看到的事情,但它没有触发触发器。

name: ABC

on:
  push:
    branches:  [master/my-directory]
  pull_request:
    branches: [ master ]

标签: githubgithub-actions

解决方案


push有一个属性叫做paths

name: ABC
on:
  push:
    branches:
      - master
    paths:
      - my-directory/**

这只会在目录树master发生更改的情况下推送到分支时触发。my-directory有关所有可能的过滤器模式,请参阅过滤器模式备忘单


推荐阅读