gpt4 book ai didi

pull-request - Github 操作 : Is there a way to run actions on Pull Requests opened from specific branches?

转载 作者:行者123 更新时间:2023-12-04 12:16:44 24 4
gpt4 key购买 nike

我正在尝试创建一个操作,当针对 master 打开来自特定分支的拉取请求时,该操作的工作流会运行。我目前在所有分支针对 master 打开的所有 Pull 请求上运行工作流。

name: Auto Approve Pull Request
on:
pull_request:
branches:
- 'master'
- 'skip-*'

jobs:
build:
name: Approve PR
runs-on: ubuntu-latest
steps:
- name: Fetch out code
uses: username/my-github-repo@master
with:
token: ******
env:
BRANCH_PREFIX: "skip-*"
PULL_REQUEST_BRANCH: "master"


我想让工作流只在名为 skip-* 的分支上运行.

最佳答案

我找到的解决方案是使用 if 语句来检查 head-ref 分支名称是否匹配(以)skip- .

这是我的解决方案:

name: Auto Approve Pull Request
on:
pull_request:
branches:
- 'master'

jobs:
build:
name: Approve PR
runs-on: ubuntu-latest
if: startsWith(github.head_ref, 'skip-') == true
steps:
- name: Fetch out code
uses: username/my-github-repo@master
with:
token: ******
env:
BRANCH_PREFIX: "skip-*"
PULL_REQUEST_BRANCH: "master"

笔记:

关于pull-request - Github 操作 : Is there a way to run actions on Pull Requests opened from specific branches?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60929760/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com