我的自动化作业可以追加到远程分支而不获取最新的提示吗?

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

我有四个作业(通过 GitHub 操作)并行运行并提交到存储库。这会产生一种竞争条件,如果一个作业首先完成推送,其他作业就会失败:

error: failed to push some refs to 'https://github.com/amingilani/canada-amateur-radio-test-bank-archive'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. If you want to integrate the remote changes,
hint: use 'git pull' before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

不幸的是,

git pull
并不能解决这个问题,因为在获取作业A中的当前提示后,另一个作业可能会在作业A可以提交和推送之前推送提交。这将导致同样的错误。

有没有一种方法可以将基于过时父引用的提交追加到远程分支的提示中,而无需:

  1. 首先获取当前提示,或者
  2. 覆盖分支

非 GitHub.com 遥控器的潜在解决方案

使用服务器端挂钩来处理提交。如果提交的引用已过时,请更新引用。

不幸的是,这在我的场景中不起作用,因为我在 GitHub.com 上。

git github
1个回答
0
投票

由于 GitHub.com 不提供服务器端挂钩,并且

git push
不允许修改。我目前最好的解决方案是按顺序运行每个作业。

我在 GitHub actions 中通过为 3/4 个作业指定

needs
参数来实现这一点,每个作业都指向文件中位于其上方的作业。

这使得操作的总运行时间更长,但它回避了问题中概述的问题。

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