在 Pull 请求上触发 GitHub 工作流程

问题描述 投票:0回答:2

我是 GitHub 工作流程的新手,请原谅这个天真的问题。我想设置一个工作流程,在打开或重新打开拉取请求时触发。我设置了一个工作流程,但它似乎只有在从我的分支到主分支进行 PR 时才会触发。

我的工作流程是在master上设置的,这就是为什么工作流程只有在PR提交给master时才会触发吗?如何更改它,以便在将 PR 提交到我的存储库中的任何分支时触发工作流程?

以下是我设置的工作流程:

# This is a basic workflow to help you get started with Actions

name: WorkflowTest

# Controls when the workflow will run
on:
  # Triggers the workflow on push or pull request events but only for the master branch
  pull_request:
    types: [opened, reopened]

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
  # This workflow contains a single job called "build"
  build:
    # The type of runner that the job will run on
    runs-on: [self-hosted, common-8gb]

    # Steps represent a sequence of tasks that will be executed as part of the job
    steps:
      # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
      #- uses: actions/checkout@v2

      # Runs a single command using the runners shell
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v2
        with:
          node-version: "14"
      - run: npm install
      - run: npm --version


github-actions
2个回答
4
投票

这对我有用。每当我从自定义分支创建 PR 进行开发时,它都会触发 CI 操作。每当我推动新的变化来开发时

name: Groot-UI CI

on:
  pull_request:
    branches: [develop]

0
投票

有时工作流程不会立即自动触发,因为 GitHub 服务器目前可能负载较重或者存在一些问题。这个问题非常罕见,而且并不是真正可以轻松检查的问题。检查这一点的最佳方法是尝试运行您最近运行过并且知道应该运行的操作。

其他时候,操作/PR 页面不会自动刷新,您必须手动刷新。因此,在进一步研究问题之前,首先尝试刷新总是值得的。

如果上述两项均按预期工作,则问题可能出在您的实际工作流程文件上。您可以随时尝试删除对其的任何限制,然后慢慢将它们一一添加回来,看看问题出在哪里。

© www.soinside.com 2019 - 2024. All rights reserved.