Code Monkey home page Code Monkey logo

Comments (5)

peter-evans avatar peter-evans commented on July 18, 2024 1

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

from create-pull-request.

peter-evans avatar peter-evans commented on July 18, 2024

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.

from create-pull-request.

Silvest89 avatar Silvest89 commented on July 18, 2024

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

from create-pull-request.

antoineqian avatar antoineqian commented on July 18, 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 ?

from create-pull-request.

peter-evans avatar peter-evans commented on July 18, 2024

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.

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.