简体   繁体   中英

Can I edit the main.workflow github-actions file locally?

If I change my main.workflow file locally, not in the master branch, the commit and push the change, I get this error from push command:

> 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'

Still experiencing this, even with .yml workflow files. Turns out that for me it was due to me using an HTTPS remote instead of SSH.

To work around this issue in the Github API, I simply used an SSH remote instead of HTTPS.

You can see if you are using HTTPS or SSH by

$ git remote -v
> origin  https://github.com/USERNAME/REPOSITORY.git (fetch)
> origin  https://github.com/USERNAME/REPOSITORY.git (push)

Notice if there is a https:// instead of git (SSH).

Then do

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

Then verify the change

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

Further Reading : Github Docs on Switching remote URLs from HTTPS to SSH

If you are using GitHub desktop there is currently a bug that causes this error when attempting to push commits from GitHub Actions. As a workaround, you can use the Git API until the fix for this issue is released.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM