我有两个工作流文件。一个是test.xml,另一个是merge.xml
test.xml运行php单元测试,如果测试成功,它将创建一个到staging分支(test.xml在feature分支中运行(的pull请求。
奇怪的是,如果pull请求发生冲突,则不会触发merge.xml工作流。但是当pull请求没有任何冲突时,它将运行并合并pull请求。我的xml配置错误了吗?
这是xml。
Test.xml
name: Test
on:
push:
branches-ignore:
- staging
jobs:
run-test:
runs-on: self-hosted
steps:
- name: run test
pullrequest-to-staging:
needs: [run-test]
runs-on: self-hosted
steps:
- name: Checkout current branch
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Create Pull Request to staging
uses: repo-sync/pull-request@v2
with:
github_token: ${{ secrets.BOT_TOKEN }}
pr_title: "Pulling ${{ steps.branch_name.outputs.branch }} into staging"
pr_body: ":crown: *An automated PR*"
destination_branch: "staging"
pr_label: "automerge"
merge.xml
name: merge-to-staging
on:
pull_request:
branches:
- staging
jobs:
merge-to-staging:
runs-on: self-hosted
steps:
- name: Label merge conflicts
uses: eps1lon/actions-label-merge-conflict@v2.0.0
with:
repoToken: "${{ secrets.BOT_TOKEN }}"
dirtyLabel: "conflicts"
continueOnMissingPermissions: true
- name: Merge to staging
uses: pascalgn/automerge-action@v0.12.0
env:
GITHUB_TOKEN: "${{ secrets.BOT_TOKEN }}"
不幸的是,如果pull请求有合并冲突,那么pull_request
应该触发的操作将不会运行。这是GitHub操作的限制,如下所述:https://github.community/t/run-actions-on-pull-requests-with-merge-conflicts/17104/2
根据GitHub文档,这是预期的
注意:如果pull请求存在合并冲突,工作流将不会在pull_request活动上运行。必须首先解决合并冲突。
他们还记录了可以使用pull_request_target
,然后:
与解决方案一起使用:相反pull_request_target事件将运行,即使pull请求具有合并冲突。在使用pull_request_target触发器之前应该意识到安全风险。有关详细信息,请参阅pull_request_target。