Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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'
like image 945
baruchiro Avatar asked Jun 14 '19 14:06

baruchiro


People also ask

How do I edit an action workflow in GitHub?

In your repository, browse to the workflow file you want to edit. In the upper right corner of the file view, to open the workflow editor, click . To the right of the editor, use the GitHub Marketplace sidebar to browse actions.

Can I run GitHub workflow locally?

github/workflows/ files (or for any changes to embedded GitHub actions), you can use act to run the actions locally. The environment variables and filesystem are all configured to match what GitHub provides. Local Task Runner - I love make.

Can you have multiple workflows in GitHub Actions?

Workflows are defined in the . github/workflows directory in a repository, and a repository can have multiple workflows, each of which can perform a different set of tasks.

Which file format is used by GitHub Actions workflows?

GitHub Actions uses YAML syntax to define the workflow. Each workflow is stored as a separate YAML file in your code repository, in a directory named .github/workflows .

Where are GitHub Actions located?

On GitHub.com, navigate to the main page of the repository. Under your repository name, click Actions. In the left sidebar, click the workflow you want to see. Under "Workflow runs", click the name of the run you want to see.


2 Answers

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 [email protected]:USERNAME/REPOSITORY.git

Then verify the change

$ git remote -v
# Verify new remote URL
> origin  [email protected]:USERNAME/REPOSITORY.git (fetch)
> origin  [email protected]:USERNAME/REPOSITORY.git (push)

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

like image 132
Scott Avatar answered Sep 22 '22 07:09

Scott


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.

like image 20
Andrea Griffiths Avatar answered Sep 24 '22 07:09

Andrea Griffiths