Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Push the formatting changes to the fork on:pull_request #54

Open
yaacine opened this issue Dec 19, 2020 · 1 comment
Open

Push the formatting changes to the fork on:pull_request #54

yaacine opened this issue Dec 19, 2020 · 1 comment

Comments

@yaacine
Copy link

yaacine commented Dec 19, 2020

Hi 👋
thanks for the great job you did on this action ,

I was trying to commit the formatted files into a PR made from a fork on a private repository (where this feature of running workflows from forks is enabled).
So I used this action

    # push the formatting changes to the PR itself
      - name: Commit autopep8 changes
        if: steps.autopep8.outputs.exit-code == 2
        run: |
          git config --global user.name 'Peter Evans'
          git config --global user.email '[email protected]'
          git commit -am "Automated autopep8 fixes"
          git push

but it seems that it's trying to push to the base repo not the fork itself.
and I got this error


remote: Repository not found.
fatal: repository 'https://github.com/<org_name>/<repo_name>/' not found
Error: Process completed with exit code 128.

Knowing that there are couple of developers who forked this repo and want to run the formatting action when they open a PR to the base repo ,Is there any way to address my use case please ?

Thanks in advance.

@peter-evans
Copy link
Owner

Hi @yaacine

I'm not sure if what you want to do is possible. There are a number of issues with trying to make this kind of workflow work for forks. I don't really recommend it, and as I mention in the readme, I recommend using a slash command style "ChatOps" solution for these kind of operations on pull requests. See slash-command-dispatch for such a solution.

To try and fix your problem, you need to make sure that the pull request branch is being checked out. If you look at the example linked below you can see that it checks out github.head_ref. You will need to do something similar to checkout the pull request branch from the fork.
https://github.com/peter-evans/autopep8#direct-push-with-on-pull_request-workflows

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants