Code Monkey home page Code Monkey logo

Comments (5)

peter-evans avatar peter-evans commented on August 20, 2024

Hi @jderusse

Interesting use case! Try the following workflow. I've not had chance to test it yet, but I think it might work. You will need to create a repo scoped Personal Access Token (PAT) so that the main repo can create a pull request in the remote repository.

Do you need the Task step? I'm assuming you just want to update the fork's master branch from the master branch of the main repo.

    - name: Set up SSH
      uses: webfactory/[email protected]
      with:
        ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}

    - uses: actions/checkout@v2
       with:
         ref: master

    - name: Set remote URL
      run: |
        git remote set-url origin [email protected]:fork/fork.git .
   
    - name: Create Pull Request
      uses: peter-evans/create-pull-request@v2
      with:
        token: ${{ secrets.PAT }}
        branch: bot-code-update

from create-pull-request.

jderusse avatar jderusse commented on August 20, 2024

hello @peter-evans, thanks for the fast reply

I think there is a missunderstood. The PR should not be created on the fork repo, but in the main repo. The fork is used for the "head" of the PR.

In fact I try to use the exact same workflow when creating a standard PR by human

  • go to project's main repo
  • fork
  • push commit on the fork
  • create a PR on the main repo

I can "push commit on the fork" change thanks SSH private key (FYI, we don't use "deploy key", but crated a bot-user, the fork belongs to the bot)

Issue is: how to tell peter-evans/create-pull-request that base and head don't have the same repo

I followed your snippet (https://github.com/async-aws/aws/pull/375/files) but the Action seem to generate a PR in the fork (https://github.com/async-aws/aws/runs/539592083?check_suite_focus=true). see PR #1 in Created pull request #1 (bot-code-update => master)

Thanks for your help

from create-pull-request.

jderusse avatar jderusse commented on August 20, 2024

I think the "issue" (or enhancement) is here

pull_request = github_repo.create_pull(
title=title, body=body, base=base, head=branch
)

We should be able to provide the head repositorylike described in "https://developer.github.com/v3/pulls/#input"

    if head_repository is None:
      head_repository = github_repository.split("/")[0]
    head_branch = "{}:{}".format(head_repository, branch)
    try:
        pull_request = github_repo.create_pull(
            title=title, body=body, base=base, head=head_branch
        )
        print(f"Created pull request #{pull_request.number} ({branch} => {base})")
    except GithubException as e:
        if e.status == 422:
            # A pull request exists for this branch and base
            # Get the pull request
            pull_request = github_repo.get_pulls(
                state="open", base=base, head=head_branch
            )[0]
            # Update title and body
            pull_request.as_issue().edit(title=title, body=body)
            print(f"Updated pull request #{pull_request.number} ({branch} => {base})")
        else:
            print(str(e))
            raise

where head_repository is a new optionnal parameter provided by user

from create-pull-request.

peter-evans avatar peter-evans commented on August 20, 2024

Thanks for explaining further. I understand what you want to do now. Essentially, you want to push the branch to a fork and pull request to the current repository using the branch in the fork. I see how this makes sense if you use SSH because the key can just have permission for the fork not the main repo. 👍

Thanks for having a shot at implementing this. I'll take a look at your PR and make some comments.

from create-pull-request.

peter-evans avatar peter-evans commented on August 20, 2024

Thank you again for contributing this feature!

I've released it as v2.5.0 or follow the major version v2.

from create-pull-request.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.