Github 操作 pull_request 当基本分支名称为 "something/*",而不是目标分支
Github Actions pull_request when base branch has name "something/*", not target branch
尝试在 PR 来自的分支名称具有特定模式时触发 GitHub 操作。
通常你可以这样做;
name: My action name
on:
pull_request:
branches:
- 'something/**'
# ... the rest of the action
这将在拉取请求尝试合并到名为 something/any-string-here
的分支时触发操作,但是,我想要相反的结果。当基本分支具有此名称时,无论目标分支是什么,我都希望此操作 运行。
这能做到吗?还是我必须在检查分支名称的所有步骤中添加 if
语句?
/
在 paths
或 branches
触发器字段上使用时是一个特殊字符。
在这种情况下,与在正则表达式中可以完成的操作类似,您需要使用 \
.
对其进行转义
因此,要实现您想要的效果,您需要使用:
name: My action name
on:
pull_request:
branches:
- 'something\/**'
# ... the rest of the action
注:
我用 this PR which triggered this workflow 测试了它。
尝试在 PR 来自的分支名称具有特定模式时触发 GitHub 操作。
通常你可以这样做;
name: My action name
on:
pull_request:
branches:
- 'something/**'
# ... the rest of the action
这将在拉取请求尝试合并到名为 something/any-string-here
的分支时触发操作,但是,我想要相反的结果。当基本分支具有此名称时,无论目标分支是什么,我都希望此操作 运行。
这能做到吗?还是我必须在检查分支名称的所有步骤中添加 if
语句?
/
在 paths
或 branches
触发器字段上使用时是一个特殊字符。
在这种情况下,与在正则表达式中可以完成的操作类似,您需要使用 \
.
因此,要实现您想要的效果,您需要使用:
name: My action name
on:
pull_request:
branches:
- 'something\/**'
# ... the rest of the action
注:
我用 this PR which triggered this workflow 测试了它。