拉取请求触发推送工作流程

Sha*_*ami 5 github-actions

在 GitHub 存储库中,我有两个单独的 GitHub Actions 工作流程:

github/workflows/pr.yml只是构建和测试

name: Pull request workflow

on: pull_request
Run Code Online (Sandbox Code Playgroud)

github/workflows/push.yml构建、测试和部署

name: Push workflow

on: push
Run Code Online (Sandbox Code Playgroud)

创建拉取请求会触发这两个工作流程。

是否无法将它们分开或者我在这里缺少什么?

riQ*_*iQQ 4

如果您只部署某些分支,请按Push workflow以下方式进行限制:

name: Push workflow
on:
  push:
    branches:
    - master
Run Code Online (Sandbox Code Playgroud)

另一种选择是排除分支

on:
  push:
    # Sequence of patterns matched against refs/heads
    branches-ignore:
      # Push events to branches matching refs/heads/mona/octocat
      - 'mona/octocat'
      # Push events to branches matching refs/heads/releases/beta/3-alpha
      - 'releases/**-alpha'
Run Code Online (Sandbox Code Playgroud)

有关更多示例,请参阅https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#onpushpull_requestbranchestags