GitHub Actions - 忽略或排除 Dependabot Pull 请求

Ami*_*itb 26 continuous-integration github github-actions dependabot

我有一个包含Dependabot的存储库,它可以打开有关版本更新等的 PR,我想保留这些内容。

在同一个存储库中,我有一个用于拉取请求的 GitHub 操作供我的团队使用。

我的问题是,无论我尝试什么,Dependabot 都会不断触发拉取请求操作。

我的 PR 操作必须在暂存分支拉取请求时触发,如下所示:

name: Pull Request
on:
  pull_request:
    branches:
      - staging
Run Code Online (Sandbox Code Playgroud)

所以我不能在 pull_reuqest 和 Branch_ignore 上同时使用 - 如文档中所述

到目前为止我已经尝试过的工作流程尝试不幸的是没有奏效:

name: Pull Request
on:
  pull_request:
    branches:
      - staging
      - '!dependabot/**'
Run Code Online (Sandbox Code Playgroud)
name: Pull Request
on:
  pull_request:
    branches:
      - staging

jobs:
  Build:
    if: github.actor!= 'dependabot-preview[bot]'
    name: Build
    runs-on: ubuntu-latest
    steps:
    - name: Check out code
      uses: actions/checkout@v2
Run Code Online (Sandbox Code Playgroud)

我也尝试过排除 Dependabot 用户,如下所示:

if: github.actor!= 'depbot'
Run Code Online (Sandbox Code Playgroud)

希望获得有关您如何处理此问题的一些见解或答案。

谢谢!

Max*_*sky 44

我想这些年来发生了很多变化,你可以在网络上找到过时的方法。实际的方式记录在 Dependabot 文档中

if: ${{ github.actor != 'dependabot[bot]' }}
Run Code Online (Sandbox Code Playgroud)

请注意,现在您还可以选中github.triggering_actor- 如果您希望在 Dependabot 触发工作流程时跳过工作流程,但希望能够在 Dependabot 打开的 PR 上手动触发它。