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

Create PR from push on a given branch #544

Closed
funes79 opened this issue Sep 5, 2020 · 3 comments
Closed

Create PR from push on a given branch #544

funes79 opened this issue Sep 5, 2020 · 3 comments

Comments

@funes79
Copy link

funes79 commented Sep 5, 2020

Subject of the issue

I have a question. I configured this action to list on "on push" events on "users" branch. What I would like to know if this action can use the very same branch for PR create or it must use always a new branch to create? I tried to configure the branch parameter and set it to the same branch "users" from where the push is coming, but this resulted in a loss of the original branch (probaly re-create).

So I would like to configure a very simple scenario:
Every time a change is pushed into my branch, I would like to open a new PR againts master, approve and merge.

Thanks

@peter-evans
Copy link
Owner

peter-evans commented Sep 5, 2020

Hi @funes79

The branch name that you specify in the branch input cannot be an existing branch, but what you can do is create and update a third branch which performs the merge. I think this example fits your use case.

This will create a pull request to merge in to master whenever there are changes on the users branch.

name: Update master from users
on:
  push:
    branches:
      - users
jobs:
  createPullRequest:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
        with:
          ref: master
      - name: Reset master branch with users changes
        run: |
          git fetch origin users:users
          git reset --hard users
      - name: Create Pull Request
        uses: peter-evans/create-pull-request@v3
        with:
          branch: users-update

@funes79
Copy link
Author

funes79 commented Sep 7, 2020

Hi @peter-evans ,
I came up with a similar solution, just doing soft reset:

      - name: Reset master branch
        run: |
          git fetch origin master:master
          git reset --soft origin/master

So in this case I always have all the changes in the users-update transferred from users. I will need to test out your recommendation, thank you

@peter-evans
Copy link
Owner

Closing this for now since it looks like you have a solution.

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