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

NO PR created and branch changes to new branch and updates from main #2889

Closed
grndvl1 opened this issue May 15, 2024 · 5 comments
Closed

NO PR created and branch changes to new branch and updates from main #2889

grndvl1 opened this issue May 15, 2024 · 5 comments

Comments

@grndvl1
Copy link

grndvl1 commented May 15, 2024

Subject of the issue

Previous steps I created a new branch that automatically sets and pushes changes to build.gradle.kts file and updates the versionName and code. I wanted to create a PR automatically then. But not have it approve it too. Problem is my new branch get overwritten with main changes. And no PR is created or commits are actually logged. I can see the branch created but no commit history, it's very odd never seen that before. Yet before the this PR step I can view the file and the changes are there before the PR creation step

Steps to reproduce

manual workflow

@peter-evans
Copy link
Owner

Hi @grndvl1

Previous steps I created a new branch

I think this is a misunderstanding about how this action works. This action expects to be creating and managing the PR branch itself. The branch input should not be an existing branch that already contains your changes.

I can't see your linked workflow, probably because the repository is private. If you show me your workflow I'll try to help you further.

@Silvest89
Copy link

This action does not just create a pr but first commits and pushes current working changes.

@antoineqian
Copy link

antoineqian commented May 22, 2024

Hi @peter-evans
First I don't know if I should create a new question. Let me know and I will. But my issue is basically the same.
My workflow looks like this

on:
  workflow_call:
  push:
    branches:
      - dev
      jobs:
  open-pr:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v2
      
      - uses: tibdex/github-app-token@v1
        id: generate-token
        with:
          app_id: ${{ secrets.APP_ID }}
          private_key: ${{ secrets.APP_PRIVATE_KEY }}
          

      - name: Open PR from dev to main
        uses: peter-evans/create-pull-request@v6
        with:
          token: ${{ steps.generate-token.outputs.token }}
          base: main 
          branch: "upgrade-from-dev-${{ github.run_id }}"
          title: "Update main from dev"
          body: "Automatically opened PR to merge dev into main."
      

My goal is that whenever a new commit is pushed to dev (ie., when a PR targeting dev is closed and merged), this workflow should create a PR to merge those new changes into the main branch, if such PR does not already exists.

In the logs of the action I see (removed some useless lines)

/usr/bin/git symbolic-ref HEAD --short
  dev
  Working base is branch 'dev'
  /usr/bin/git checkout --progress -B 9d1f8d9f-345b-4852-8b[43](https://github.com/XXXX/actions/runs/9192830460/job/25282452556#step:4:49)-16201aa49f1d HEAD --
  Switched to a new branch '9d1f8d9f-345b-4852-8b43-16201aa49f1d'
  /usr/bin/git status --porcelain -unormal --
  /usr/bin/git diff --quiet --
  /usr/bin/git diff --quiet --staged --
  /usr/bin/git stash push --include-untracked
  No local changes to save
  Resetting working base branch 'dev'
  /usr/bin/git checkout --progress dev --
  Switched to branch 'dev'
  Your branch is up to date with 'origin/dev'.
  /usr/bin/git reset --hard origin/dev
  HEAD is now at d6ca65f Merge pull request #69 from XXX/some-change
  Rebasing commits made to branch 'dev' on to base branch 'main'
  /usr/bin/git -c protocol.version=2 fetch --no-tags --progress --no-recurse-submodules --force --depth=1 origin main:main
  remote: Enumerating objects: 11, done.          
  remote: Counting objects: 100% (11/11), done.            
  remote: Compressing objects: 100% (6/6), done.        
  remote: Total 6 (delta 5), reused 0 (delta 0), pack-reused 0        
  From https://github.com/Ynstant/brevo
   * [new branch]      main       -> main
   * [new branch]      main       -> origin/main
  /usr/bin/git checkout --progress main --
  Switched to branch 'main'
  /usr/bin/git rev-list --reverse dev..9d1f8d9f-345b-4852-8b43-16201aa49f1d .
  /usr/bin/git checkout --progress -B 9d1f8d9f-345b-4852-8b43-16201aa49f1d HEAD --
  Switched to and reset branch '9d1f8d9f-345b-4852-8b43-16201aa49f1d'
  /usr/bin/git -c protocol.version=2 fetch --no-tags --progress --no-recurse-submodules --force --depth=1 origin main:main
  remote: Total 0 (delta 0), reused 0 (delta 0), pack-reused 0        
  /usr/bin/git rev-list --right-only --count main...9d1f8d9f-345b-4852-8b43-16201aa49f1d
  0
  /usr/bin/git -c protocol.version=2 fetch --no-tags --progress --no-recurse-submodules --force --depth=10 origin upgrade-from-dev-9192830[46](https://github.com/XXX/actions/runs/9192830460/job/25282452556#step:4:52)0:refs/remotes/origin/upgrade-from-dev-9192830460
  fatal: couldn't find remote ref upgrade-from-dev-9192830460
  Pull request branch 'upgrade-from-dev-9192830460' does not exist yet.
  /usr/bin/git checkout --progress -B upgrade-from-dev-9192830460 9d1f8d9f-345b-[48](https://github.com/XXX/actions/runs/9192830460/job/25282452556#step:4:54)52-8b43-16201aa49f1d --
  Switched to a new branch 'upgrade-from-dev-9192830460'
  /usr/bin/git rev-list --right-only --count main...upgrade-from-dev-9192830460
  0

So it seems that the branch specified in the branch parameter is, after some rebasing that I don't understand, at the same place as the main branch which is not what I expected.

It's not clear to me from the doc how the action works, and it seems i'm not using it properly. Can you understand and fix my workflow ?

@peter-evans
Copy link
Owner

Hi @antoineqian,

You are trying to create a PR where the changes already exist in a branch. There's a section in the docs about this, with possible solutions: https://github.com/peter-evans/create-pull-request/blob/main/docs/common-issues.md#create-using-an-existing-branch-as-the-pr-branch

@peter-evans
Copy link
Owner

I'm closing this now because this isn't really an issue with the action, it's just a bit of misunderstanding about how the action works.

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

5 participants
@grndvl1 @Silvest89 @peter-evans @antoineqian and others