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

PR branch is not ahead of base 'main' and will not be created #3575

Open
petlitskiy opened this issue Dec 18, 2024 · 4 comments
Open

PR branch is not ahead of base 'main' and will not be created #3575

petlitskiy opened this issue Dec 18, 2024 · 4 comments

Comments

@petlitskiy
Copy link

Subject of the issue

Action creates PR from repo A to repo B. And (very rarely) we are faced with

 Branch 'deploy-pr-1498-...' is not ahead of base 'main' and will not be created

After we have renewed with new commits - we can recreate the target PR (refreshed with new commits as well).

Looks like another PR succeeded and merged to the main branch on repo B at the moment of creation of the first mentioned PR (from repo A).

Steps to reproduce

Is there any option on this action that provides retries of PR creation for some time with some pause periods?

@peter-evans
Copy link
Owner

Hi @petlitskiy

I'm not sure I understand your use case. If you show me your workflow(s) I might be able to help.

Is there any option on this action that provides retries of PR creation for some time with some pause periods?

The only retry that occurs is for retryable errors from the API. There's no other retry options.

@gomeology
Copy link

gomeology commented Jan 1, 2025

`
- name: Raise Pull Request
uses: peter-evans/create-pull-request@v7
permissions:
pull-requests: write
with:
token: ${{ secrets.TOKEN }}
commit-message: |
the first line is the commit message

        the commit description starts
        after a blank line and can be
        multiple lines
      #base: main defaults to check out branch
      committer: forgejo-runner[bot] <[email protected]>
      author: ${{ github.actor }} <${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com>
      signoff: false
      branch: bot/updates
      delete-branch: true
      title: "Generated PR from ${{ env.GIT_COMMIT_SHORT_SHA }}"
      body: |
        This PR was automatically generated from commit ${{ env.GIT_COMMIT_SHORT_SHA }}.
        The author of the commit was ${{ github.actor }}.
        The commit message was: ${{ env.GIT_COMMIT_MESSAGE_SUBJECT }}.
      labels: |
        report
        automated pr
      draft: false

##[group]Checking the base repository state
[command]/usr/bin/git symbolic-ref HEAD --short
me
Working base is branch 'me'
[command]/usr/bin/git remote prune origin
##[endgroup]
Pull request branch to create or update set to 'bot/updates'
##[group]Configuring the committer and author
Configured git committer as 'forgejo-runner[bot] [email protected]'
Configured git author as 'zero [email protected]'
##[endgroup]
##[group]Create or update the pull request branch
[command]/usr/bin/git symbolic-ref HEAD --short
me
Working base is branch 'me'
[command]/usr/bin/git checkout --progress -B 93f53b0c-f653-478e-847e-e7777c70094a HEAD --
Switched to a new branch '93f53b0c-f653-478e-847e-e7777c70094a'
[command]/usr/bin/git status --porcelain -unormal
[command]/usr/bin/git diff --quiet
[command]/usr/bin/git diff --quiet --staged
Resetting working base branch 'me'
[command]/usr/bin/git checkout --progress me --
Switched to branch 'me'
Your branch is up to date with 'origin/me'.
[command]/usr/bin/git reset --hard origin/me
HEAD is now at 785e180 Quick commit
[command]/usr/bin/git -c protocol.version=2 fetch --no-tags --progress --no-recurse-submodules --unshallow origin bot/updates:refs/remotes/origin/bot/updates
fatal: couldn't find remote ref bot/updates
Pull request branch 'bot/updates' does not exist yet.
[command]/usr/bin/git checkout --progress -B bot/updates 93f53b0c-f653-478e-847e-e7777c70094a --
Switched to a new branch 'bot/updates'
[command]/usr/bin/git rev-list --right-only --count me...bot/updates
0
Branch 'bot/updates' is not ahead of base 'me' and will not be created
[command]/usr/bin/git rev-parse HEAD
785e1800c9649af2fb42ee78a1701c5d600ce3ed
[command]/usr/bin/git branch --delete --force 93f53b0c-f653-478e-847e-e7777c70094a
Deleted branch 93f53b0c-f653-478e-847e-e7777c70094a (was 785e180).
##[endgroup]
`

testing senario is created a fresh repo. added the workflow. created several test branches add random crap and sent it off to see if it create a pr request it says the same thing. branch is not ahead.

@peter-evans
Copy link
Owner

@gomeology I need to see the whole workflow, not just the action step. It matters what triggers the workflow and what changes you are making before the action runs.

@gomeology
Copy link

@peter-evans ok so maybe i misunderstood what this is doing. when looking at your example i have to add date+%S > report.txt. is this because it needs to be modified from within the workflow? Im new to this so bear with me. But I want to create a PR whenever a new push is made. I now added your date command line and I am getting "::error::Not found.%0A". im guessing this is because the token is not getting to where it needs to be. but here is the workflow. Can you also answer if i need the 'make changes to pull request' for this to work?

`
name: MyFunctions Module Testing and Analysis

on:
push:
Merge:

jobs:
test-and-analyze:
runs-on: docker
image: ubuntu-latest

steps:
  - name: Checkout code
    uses: actions/checkout@v4

  - name: Expose git commit data
    uses: https://github.com/rlespinasse/[email protected]

  - name: Print git commit data
    run: |
      echo "Get commit info"
      echo " - ${{ env.GIT_COMMIT_SHA }}"
      echo " - ${{ env.GIT_COMMIT_SHORT_SHA }}"
      echo "Get author info"
      echo " - ${{ env.GIT_COMMIT_AUTHOR }}"
      echo " - ${{ env.GIT_COMMIT_AUTHOR_NAME }}"
      echo " - ${{ env.GIT_COMMIT_AUTHOR_EMAIL }}"
      echo "Get committer info"
      echo " - ${{ env.GIT_COMMIT_COMMITTER }}"
      echo " - ${{ env.GIT_COMMIT_COMMITTER_NAME }}"
      echo " - ${{ env.GIT_COMMIT_COMMITTER_EMAIL }}"
      echo "Get message info"
      echo " - ${{ env.GIT_COMMIT_MESSAGE_SUBJECT }}"
      echo " - ${{ env.GIT_COMMIT_MESSAGE_SUBJECT_SANITIZED }}"
      echo " - ${{ env.GIT_COMMIT_MESSAGE_BODY }}"

  - name: Make changes to pull request
    run: date +%s > report.txt

  - name: Raise Pull Request
    uses: peter-evans/create-pull-request@v7
    permissions:
      pull-requests: write
    token: ${{ secrets.TOKEN }} #PAT
    commit-message: |
      the first line is the commit message

      the commit description starts
      after a blank line and can be
      multiple lines
    #base: main defaults to check out branch
    committer: forgejo-runner[bot] <[email protected]>
    author: ${{ github.actor }} <${{ github.actor_id }}+${{ github.actor }}@selfhosted.dev>
    signoff: false
    branch: bot/updates
    delete-branch: true
    title: "Generated PR from ${{ env.GIT_COMMIT_SHORT_SHA }}"
    body: |
      This PR was automatically generated from commit ${{ env.GIT_COMMIT_SHORT_SHA }}.
      The author of the commit was ${{ github.actor }}.
      The commit message was: ${{ env.GIT_COMMIT_MESSAGE_SUBJECT }}.
    labels: |
      report
      automated pr
    draft: false

`

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

3 participants