当在与“main”不同的分支上合并拉取请求时,Github 操作不会触发

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

我目前有 2 个工作流程来在链接到我的

main
分支的项目上构建我的背部和正面。 这个工作流程完美运行。

因此,我复制了此工作流程以执行相同的过程,但对于第二个

pre-prod
分支,从而在我的预生产服务器上进行构建。

这些新的工作流程永远不会触发尽管我多次尝试。

这是适用于我的

main
分支的当前工作流程:

name: Check update and deploy backend
on:
  pull_request:
    branches:
      - main
    types:
      [closed]
    paths:
      - 'back/**'

jobs:
  changed_files:
    if: ${{ github.event.pull_request.merged }}
    name: Deploy backend
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 2

      - name: Set up Node.js
        uses: actions/setup-node@v4
        with:
          node-version: '20.x'

      - name: Install dependencies
        run: 
          cd back && npm install
// and other jobs tasks

因此,我进行了必要的修改以实现相同的目标,但是当将分支合并到我的

pre-prod
分支时:

name: Check update and deploy preprod backend
on:
  pull_request:
    branches:
      - pre-prod
    types:
      [closed]
    paths:
      - 'back/**'

jobs:
  changed_files:
    if: ${{ github.event.pull_request.merged }}
    name: Deploy backend
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 2

      - name: Set up Node.js
        uses: actions/setup-node@v4
        with:
          node-version: '20.x'

      - name: Install dependencies
        run: 
          cd back && npm install
// and other jobs tasks

我的

.github/workflows
文件夹位于
main
pre-prod
分支以及我的
feature-branch
的项目根目录,必须从我的分支合并。

因此,提交后永远不会触发此工作流程,然后将请求拉取到

remote/pre-prod
,然后从此 PR 合并。

github github-actions cicd
1个回答
0
投票

使用 GitHub Actions,有时需要几个小时才能完成设置。您今天就可以启动它,它应该可以工作,因为您的示例中没有问题。

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