【问题标题】:Can I edit the main.workflow github-actions file locally?我可以在本地编辑 main.workflow github-actions 文件吗?
【发布时间】:2019-10-29 05:45:06
【问题描述】:

如果我在本地更改我的main.workflow 文件,而不是在master 分支中,提交并推送更改,我会从push 命令收到此错误:

> git diff
diff --git a/.github/main.workflow b/.github/main.workflow
index 135d8ea..0a13a28 100644
--- a/.github/main.workflow
+++ b/.github/main.workflow
@@ -6,7 +6,7 @@ workflow "Build and Test in PR" {
   ]
 }

-action ".NET Core CLI" {
+action ".NET Core CLI"  {
   uses = "./.github/net-core/"
   args = "test"
 }

> git push
! [remote rejected] my-branch -> my-branch (refusing to allow an integration to create or update .github/main.workflow)
error: failed to push some refs to 'https://github.com/my-user-name/my-repo.git'

【问题讨论】:

  • 抱歉,无法重现。您是否有机会使用 GitHub Desktop 进行推送?截至目前,它无法处理main.workflows。
  • @maxheld 问题可能出在 Github 中的存储库设置上。

标签: git github github-actions


【解决方案1】:

即使使用.yml 工作流文件,仍然会遇到这种情况。事实证明,对我来说,这是因为我使用的是 HTTPS 远程而不是 SSH。

为了在 Github API 中解决这个问题,我只是使用了 SSH 远程而不是 HTTPS。

你可以通过

查看你使用的是HTTPS还是SSH
$ git remote -v
> origin  https://github.com/USERNAME/REPOSITORY.git (fetch)
> origin  https://github.com/USERNAME/REPOSITORY.git (push)

注意是否存在 https:// 而不是 git (SSH)。

那么做

git remote set-url origin git@github.com:USERNAME/REPOSITORY.git

然后验证更改

$ git remote -v
# Verify new remote URL
> origin  git@github.com:USERNAME/REPOSITORY.git (fetch)
> origin  git@github.com:USERNAME/REPOSITORY.git (push)

延伸阅读:Github Docs on Switching remote URLs from HTTPS to SSH

【讨论】:

    【解决方案2】:

    如果您使用的是 GitHub 桌面,则当前有一个错误会在尝试从 GitHub 操作推送提交时导致此错误。作为一种解决方法,您可以使用 Git API,直到此问题的修复程序发布。

    【讨论】:

      猜你喜欢
      • 2019-11-28
      • 1970-01-01
      • 2020-08-03
      • 2022-07-13
      • 1970-01-01
      • 2011-09-24
      • 1970-01-01
      • 2020-12-21
      • 1970-01-01
      相关资源
      最近更新 更多